blackrabt

BigReactors Pocket monitor wip

Mar 1st, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. wirelessSide = "back" --the pocket computer modem is always on the back
  2. local wireless = peripheral.wrap(wirelessSide)
  3. rednet.open(wirelessSide)
  4. print("Opened modem on "..wirelessSide.." side")
  5. wireless.open(65535) -- adding this channel will allow rednet repeaters to send the message farther
  6. rednet.send(9, "request") --put then ID of your reactor linked computer (the one running the server code) where 9 is.
  7.  
  8. function printInfo()
  9.   if rednet.receive(2) then --wait 2 seconds to get a reply from the reactor server or assume it is busy
  10.    id, message = rednet.receive()
  11.   print ("Reactor Computer " .. id .. " answered")
  12.   print ("-" .. message .. " ")
  13.   i, m = rednet.receive() --shouldn't this be id not i?
  14.   print ("-" .. m .. " ")
  15.   id2, m2 = rednet.receive()
  16.   print ("-" .. m2 .. " ")
  17.   os.sleep(3) --give the user 3 seconds to read the information before clearing and returning to the main shell
  18.   term.clear()
  19.   term.setCursorPos(1,1)
  20.   --error()
  21.   --os.reboot()
  22.   return
  23.   end
  24. end
  25. if rednet.receive(2) then --wait 2 seconds to get a reply from the reactor server or assume it is busy
  26.    id, message = rednet.receive()
  27.   print ("Reactor Computer " .. id .. " answered")
  28.   print ("-" .. message .. " ")
  29.   i, m = rednet.receive() --shouldn't this be id not i?
  30.   print ("-" .. m .. " ")
  31.   id2, m2 = rednet.receive()
  32.   print ("-" .. m2 .. " ")
  33.   os.sleep(3) --give the user 3 seconds to read the information before clearing and returning to the main shell
  34.   term.clear()
  35.   term.setCursorPos(1,1)
  36.   --error()
  37.   --os.reboot()
  38.   return
  39. else
  40.   wait = 1
  41.   while wait < 5 do
  42.     rednet.send(9, "request")
  43.     wait = wait + 1
  44.     if rednet.receive(0.5) then
  45.       printInfo
  46.     end
  47.   print("The reactor was busy, please try again.")
  48.   sleep(1)
  49.   return
  50. end
  51. return
Advertisement
Add Comment
Please, Sign In to add comment