Advertisement
Tomyf4

ReactorSuperStructureComputer

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