Advertisement
Guest User

ReactorReader

a guest
May 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. reactor = peripheral.wrap("nuclear_reactor_1")
  2. wired = peripheral.wrap("top")
  3. wireless = peripheral.wrap("left")
  4.  
  5. local relayID = 18
  6.  
  7. local active, euOutput, heat, heatMax
  8. local failsafeOn = false
  9.  
  10. function OpenWireless()
  11.     rednet.open("left")
  12.     rednet.close("top")
  13. end
  14.  
  15. function OpenWired()
  16.     rednet.open("top")
  17.     rednet.close("left")
  18. end
  19.  
  20. function SendToRelay(msg)
  21.     rednet.send(relayID, msg)
  22. end
  23.  
  24. function MainLoop()
  25.     while true do
  26.         sleep(1)
  27.         OpenWired()
  28.         term.clear()
  29.        
  30.         active = reactor.isActive()
  31.         euOutput = reactor.getEUOutput() * 5
  32.         heat = reactor.getHeat()
  33.         heatMax = reactor.getMaxHeat()
  34.        
  35.         OpenWireless()
  36.         SendToRelay("<active>" .. tostring(active))
  37.         SendToRelay("<euoutput>" .. euOutput)
  38.         SendToRelay("<heat>" .. heat)
  39.         SendToRelay("<heatmax>" .. heatMax)
  40.     end
  41. end
  42.  
  43. function FailSafe()
  44.     sleep(5)
  45.     if heat > (heatMax - 900) and failsafeOn == false then
  46.         redstone.setOutput("front", false)
  47.         failsafeOn = true
  48.     end
  49. end
  50.  
  51. redstone.setOutput("front", true)
  52. MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement