thatparadox

Reactor

Mar 22nd, 2013
1,588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. mon = peripheral.wrap("bottom") -- set monitor side
  2. rednet.open("right") -- set rednet side
  3. console = 146 -- enter ID of computer attached to the touch screen
  4. nir = 147 -- enter ID of computer attached to the Nuclear information reader
  5. maxTemp = 5000
  6. temp = 1000
  7. rctrStatus = "off"
  8.  
  9. while true do
  10.   a,b = rednet.receive()
  11.     if a == console then
  12.       if b == "on" then
  13.         rs.setOutput("back", true)
  14.         rctrStatus = "on"
  15.         break
  16.       elseif b == "off" then
  17.         break
  18.       end
  19.     end
  20. end      
  21.  
  22. while true do
  23.   if temp >= maxTemp then
  24.     rs.setOutput("back", false)
  25. --  elseif temp >= 7500 then
  26. --    rs.setOutput("back" ,false)
  27.   end
  28.   a,b = rednet.receive()
  29.   if a == nir then
  30.     temp = tonumber(b)
  31.   elseif a == console then
  32.     if b == "maxTemp" then
  33.       rednet.send(console, "ping")
  34.       id, message = rednet.receive()
  35.       message = tonumber(message)
  36.       --if message < 7500 and
  37.         if id == console then
  38.         maxTemp = message
  39.         rednet.send(console, "true")
  40.       else
  41.         rednet.send(console, "false")
  42.       end
  43.     elseif b == "on" then
  44.       if temp < maxTemp then
  45.         rs.setOutput("back", true)
  46.         rednet.send(console, "true")
  47.         rctrStatus = "on"
  48.         print("On received")
  49.       else
  50.         rednet.send(console, "false")
  51.       end
  52.     elseif b == "off" then
  53.       rs.setOutput("back", false)
  54.       rednet.send(console, "true")
  55.       rctrStatus ="Off"
  56.     end
  57.   end
  58.   mon.clear()
  59.   mon.setCursorPos(1,1)
  60.   mon.write("Reactor: "..rctrStatus)
  61.   mon.setCursorPos(1,3)
  62.   mon.write("Current Temp: "..temp)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment