Guest User

reactorTransmiter

a guest
Jan 17th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local reactor = peripheral.wrap("top")
  2.  
  3. local controlID = 7
  4. local active = false
  5.  
  6. function listen()
  7.   rednet.open("left")
  8.   while true do
  9.     id, msg = rednet.receive()
  10.     if msg == "Reactor true" then
  11.       active = true
  12.       print(msg)
  13.     elseif msg == "Reactor false" then
  14.       active = false
  15.       print(msg)
  16.     end
  17.   end
  18. end
  19.  
  20. function main_loop()
  21.   while true do
  22.     os.queueEvent("randomEvent")
  23.     os.pullEvent()
  24.     sendDetails()
  25.     if active == false then
  26.       reactor.setActive(false)
  27.     else
  28.       reactor.setActive(true)
  29.     end              
  30.   end
  31. end
  32.  
  33. function sendTemp()
  34.   rednet.send(controlID, "Reactor 1 temperature = " .. reactor.getFuelTemperature())
  35. end
  36.  
  37. function sendFuel()
  38.   rednet.send(controlID, "Reactor 1 fuel amount = " .. reactor.getFuelAmount() .. "/" .. reactor.getFuelAmountMax())
  39. end
  40.  
  41. function sentWater()
  42.   rednet.send(controlID, "Reactor 1 water level = " .. reactor.getCoolantAmount() .. "/" .. reactor.CoolantAmountMax())
  43. end
  44.  
  45. function sentSteam()
  46.   rednet.send(controlID, "Reactor 1 steam level = " .. reactor.getHotFluidAmount() .. "/" .. reactor.getHotFluidAmountMax())
  47. end
  48.  
  49. function sendDetails()
  50.   sendTemp()
  51.   sendFuel()
  52.   sendWater()
  53.   sendSteam()
  54.   sleep(1)
  55. end
  56.  
  57. parallel.waitForAll(listen, main_loop)
Advertisement
Add Comment
Please, Sign In to add comment