Advertisement
Tomyf4

ModularMultiBlockReactor

Feb 4th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. num = 1
  2. screennum = 1
  3. local MaxOutput = 120
  4.  
  5.  
  6.  
  7. screen = peripheral.wrap("monitor_"..screennum)
  8. speaker = peripheral.wrap("top")
  9. rednet.open("front")
  10. local Temp = 0
  11. Output = 0
  12. Power = 0
  13.  
  14. function clear()
  15. screen.setBackgroundColor(32768)
  16. screen.clear()
  17. screen.setCursorPos(1,1)
  18. end
  19.  
  20. function drawLine(x, y, length, size, color_bar)
  21. for yPos = y, y+length-1 do
  22. screen.setBackgroundColor(color_bar)
  23. screen.setCursorPos(x, yPos)
  24. screen.write(string.rep(" ", size))
  25. end
  26. end
  27.  
  28. function drawProg(x, y, length, size, minVal, maxVal, color_bar, color_bg)
  29. drawLine(x, y, length, size, color_bg)
  30. local barSize = math.floor((minVal/maxVal)*length)
  31. drawLine(x, y, barSize, size, color_bar)
  32. end
  33.  
  34. function OutputText()
  35. screen.setBackgroundColor(32768)
  36. screen.setCursorPos(2,6)
  37. screen.write(math.floor(Output * 100) / 100)
  38. end
  39.  
  40. function powerOn()
  41. for i = 0, MaxOutput do
  42. drawProg(0,7, 20, 10, i, MaxOutput, 8192, 32768)
  43. Output = i
  44. OutputText()
  45. sleep(0.001)
  46. end
  47. end
  48.  
  49. function powerOff()
  50. for i = 0, MaxOutput do
  51. drawProg(0,7, 20, 10, MaxOutput-i, MaxOutput, 16384, 32768)
  52. Output = MaxOutput-i
  53. OutputText()
  54. sleep(0.001)
  55. end
  56. clear()
  57. end
  58.  
  59. function updateStats(Status)
  60. screen.setCursorPos(2,1)
  61. screen.write(Status)
  62. screen.setCursorPos(2,3)
  63. screen.write("TEMP")
  64. screen.setCursorPos(2,4)
  65. screen.write(Temp)
  66. end
  67.  
  68. function updateScreen(Power)
  69. if Power == "ON" then
  70. clear()
  71. updateStats("ON")
  72. powerOn()
  73. elseif Power == "OFF" then
  74. clear()
  75. updateStats("OFF")
  76. powerOff()
  77. end
  78. end
  79.  
  80. clear()
  81.  
  82. while true do
  83. local id, message = rednet.receive()
  84. if message == "poweronreactor_"..num and Power == 0 then
  85. rednet.broadcast("Reactor"..num.." is Starting")
  86. redstone.setOutput("bottom", true)
  87. speaker.playSound("minecraft:ui.button.click")
  88. updateScreen("ON")
  89. Power = 1
  90. rednet.broadcast("Reactor"..num.." has Started")
  91. elseif message == "poweroffreactor_"..num and Power == 1 then
  92. rednet.broadcast("Reactor"..num.." is Shutting Down")
  93. redstone.setOutput("bottom", false)
  94. speaker.playSound("minecraft:ui.button.click")
  95. updateScreen("OFF")
  96. Power = 0
  97. rednet.broadcast("Reactor"..num.." is Offline")
  98. end
  99. sleep(0.1)
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement