Advertisement
Tomyf4

ReactorDisplayOutput

Feb 1st, 2020
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. rednet.open("back")
  2. screen = peripheral.wrap("bottom")
  3. TotalPowerOutput = 0
  4. PowerOutput = 60
  5.  
  6. r1p = 0
  7. r2p = 0
  8. r3p = 0
  9.  
  10. local function UpdateScreen()
  11. screen.clear()
  12. screen.setTextScale(2)
  13. screen.setCursorPos(2,2)
  14. screen.write("Power Output:")
  15. sleep(0.1)
  16. screen.setCursorPos(5,4)
  17. screen.write(TotalPowerOutput.." EU/t")
  18. end
  19.  
  20. UpdateScreen()
  21.  
  22. while true do
  23. local id, message = rednet.receive()
  24. if message == "Reactor1 is now ONLINE" and r1p == 0 then
  25. r1p = 1
  26. TotalPowerOutput = TotalPowerOutput + PowerOutput
  27. UpdateScreen()
  28.  
  29. elseif message == "Reactor2 is now ONLINE" and r2p == 0 then
  30. r2p = 1
  31. TotalPowerOutput = TotalPowerOutput + PowerOutput
  32. UpdateScreen()
  33.  
  34. elseif message == "Reactor3 is now ONLINE" and r3p == 0 then
  35. r3p = 1
  36. TotalPowerOutput = TotalPowerOutput + PowerOutput
  37. UpdateScreen()
  38.  
  39. elseif message == "Reactor1 is now OFFLINE" and r1p == 1 then
  40. r1p = 0
  41. TotalPowerOutput = TotalPowerOutput - PowerOutput
  42. UpdateScreen()
  43.  
  44. elseif message == "Reactor2 is now OFFLINE" and r2p == 1 then
  45. r2p = 0
  46. TotalPowerOutput = TotalPowerOutput - PowerOutput
  47. UpdateScreen()
  48.  
  49. elseif message == "Reactor3 is now OFFLINE" and r3p == 1 then
  50. r3p = 0
  51. TotalPowerOutput = TotalPowerOutput - PowerOutput
  52. UpdateScreen()
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement