LewdLamb

Untitled

Jul 11th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.54 KB | None | 0 0
  1. ----------- Made BY MJRLegends (Please dont claim as your own code) -----------
  2. version = "1.0.3"
  3.  
  4. mouseWidth = 0
  5. mouseHeight = 0
  6. rodNumber = 0
  7. rodLevel = 0
  8.  
  9. monitor = peripheral.wrap("monitor_0")
  10. reactor = peripheral.wrap("mekanism_machine_0")
  11. laser = peripheral.wrap("mekanism_machine_1") -- Front laser/closet to the reactor, of the lasers required to start the reactor
  12.  
  13. setting = false
  14.  
  15. function draw_line(x, y, length, color)
  16. monitor.setBackgroundColor(color)
  17. monitor.setCursorPos(x,y)
  18. monitor.write(string.rep(" ", length))
  19. end
  20.  
  21. function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
  22. draw_line(x, y, length, bg_color) --backgoround bar
  23. local barSize = math.floor((minVal/maxVal) * length)
  24. draw_line(x, y, barSize, bar_color) --progress so far
  25. end
  26.  
  27. function draw_text(x, y, text, text_color, bg_color)
  28. monitor.setBackgroundColor(bg_color)
  29. monitor.setTextColor(text_color)
  30. monitor.setCursorPos(x,y)
  31. monitor.write(text)
  32. end
  33.  
  34. function drawControlScreen()
  35. term.setBackgroundColor(colors.black)
  36. term.setTextColor(colors.blue)
  37. term.setCursorPos(1,1)
  38. term.write("MJRLegends Fusion Reactor Management")
  39. term.setCursorPos(1,2)
  40. term.write("Version: " .. version)
  41. monitor.setTextScale(1)
  42. monitor.clear()
  43. active = reactor.isIgnited()
  44.  
  45. -----------Title---------------------
  46. monitor.setTextColour((colours.blue))
  47. monitor.setCursorPos(1,1)
  48. monitor.write("MJRLegends Fusion Reactor Management")
  49. monitor.setTextColour((colours.white))
  50.  
  51. -----------Reactor Enable/Disable---------------------
  52. monitor.setCursorPos(1,3)
  53. monitor.write("Reactor: ")
  54. if active then
  55. monitor.setBackgroundColour((colours.blue))
  56. else
  57. monitor.setBackgroundColour((colours.grey))
  58. end
  59. monitor.setCursorPos(20,3)
  60. monitor.write(" ON ")
  61.  
  62. if active then
  63. monitor.setBackgroundColour((colours.grey))
  64. else
  65. monitor.setBackgroundColour((colours.blue))
  66. end
  67. monitor.setCursorPos(25,3)
  68. monitor.write(" OFF ")
  69. monitor.setBackgroundColour((colours.black))
  70.  
  71. -----------Section Lines---------------------
  72. displayW,displayH=monitor.getSize()
  73.  
  74. monitor.setTextColour((colours.blue))
  75. monitor.setCursorPos(0,2)
  76. monitor.write(string.rep("-", displayW))
  77. monitor.setTextColour((colours.white))
  78.  
  79. monitor.setTextColour((colours.blue))
  80. monitor.setCursorPos(0,4)
  81. monitor.write(string.rep("-", displayW))
  82. monitor.setTextColour((colours.white))
  83.  
  84. monitor.setTextColour((colours.blue))
  85. monitor.setCursorPos(0,displayH - 2)
  86. monitor.write(string.rep("-", displayW))
  87. monitor.setTextColour((colours.white))
  88.  
  89. monitor.setTextColour((colours.blue))
  90. monitor.setCursorPos(0,displayH - 0)
  91. monitor.write(string.rep("-", displayW))
  92. monitor.setTextColour((colours.white))
  93.  
  94. -----------Bottom Bar Buttons---------------------
  95. if setting then
  96. monitor.setBackgroundColour((colours.grey))
  97. else
  98. monitor.setBackgroundColour((colours.blue))
  99. end
  100. monitor.setCursorPos(displayW - 10,displayH - 1)
  101. monitor.write(" Settings ")
  102. monitor.setBackgroundColour((colours.black))
  103. end
  104.  
  105. function drawDisplayScreen()
  106. displayW,displayH=monitor.getSize()
  107. monitor.setTextScale(1)
  108.  
  109. -----------Casing Heat---------------------
  110. draw_text(2, 5, "Casing Heat: ", colors.yellow, colors.black)
  111. local maxVal = 5000000000
  112. local minVal = math.floor(tonumber(reactor.getCaseHeat()))
  113. draw_text(19, 5, minVal.." C", colors.white, colors.black)
  114.  
  115. if minVal < 100000 then
  116. progress_bar(2, 6, displayW-2, minVal, maxVal, colors.lightBlue, colors.gray)
  117. elseif minVal < math.floor((1000000000 / 2)/2) then
  118. progress_bar(2, 6, displayW-2, minVal, maxVal, colors.lime, colors.gray)
  119. elseif minVal < math.floor(1000000000 / 2) then
  120. progress_bar(2, 6, displayW-2, minVal, maxVal, colors.yellow, colors.gray)
  121. elseif minVal >= math.floor(1000000000 / 2) then
  122. progress_bar(2, 6, displayW-2, minVal, maxVal, colors.red, colors.gray)
  123. end
  124. monitor.setBackgroundColour((colours.black))
  125.  
  126. -----------Plasma Heat---------------------
  127. draw_text(2, 8, "Plasma Heat: ", colors.yellow, colors.black)
  128. local maxVal = 7350000000
  129. local minVal = math.floor(tonumber(reactor.getPlasmaHeat()))
  130. draw_text(19, 8, minVal.." C", colors.white, colors.black)
  131.  
  132. if minVal < 100000 then
  133. progress_bar(2, 9, displayW-2, minVal, maxVal, colors.lightBlue, colors.gray)
  134. elseif minVal < math.floor((1000000000 / 2)/2) then
  135. progress_bar(2, 9, displayW-2, minVal, maxVal, colors.lime, colors.gray)
  136. elseif minVal < math.floor(1000000000 / 2) then
  137. progress_bar(2, 9, displayW-2, minVal, maxVal, colors.yellow, colors.gray)
  138. elseif minVal >= math.floor(1000000000 / 2) then
  139. progress_bar(2, 9, displayW-2, minVal, maxVal, colors.red, colors.gray)
  140. end
  141. monitor.setBackgroundColour((colours.black))
  142.  
  143. -----------Laser Power Storage---------------------
  144. draw_text(2, 11, "Laser Power: ", colors.yellow, colors.black)
  145. local maxVal = 5000000000
  146. local minVal = math.floor(tonumber(laser.getStored()))
  147. draw_text(19, 11, math.floor((minVal/maxVal)*100).." % " .."("..minVal.." J)", colors.white, colors.black)
  148. progress_bar(2, 12, displayW-2, minVal, maxVal, colors.blue, colors.gray)
  149. monitor.setBackgroundColour((colours.black))
  150.  
  151. -----------Injection Rate---------------------
  152. draw_text(2, 14, "Injection Rate: ", colors.yellow, colors.black)
  153. draw_text(24, 14, reactor.getInjectionRate(), colors.white, colors.black)
  154.  
  155. -----------Has Fuel---------------------
  156. draw_text(2, 15, "Fuel: ", colors.yellow, colors.black)
  157. draw_text(24, 15, reactor.hasFuel(), colors.white, colors.black)
  158.  
  159. -----------Engery Producing---------------------
  160. draw_text(2, 16, "Engery Producing J/T: ", colors.yellow, colors.black)
  161. draw_text(24, 16, math.floor(tonumber(reactor.getProducing())) .. " J/T", colors.white, colors.black)
  162. draw_text(2, 17, "Engery Producing RF/T: ", colors.yellow, colors.black)
  163. draw_text(24, 17, math.floor(tonumber(reactor.getProducing()) / 2.5) .. " RF/T", colors.white, colors.black)
  164.  
  165. -----------Can Ignite---------------------
  166. draw_text(2, 18, "Can Ignite: ", colors.yellow, colors.black)
  167. draw_text(24, 18, reactor.canIgnite(), colors.white, colors.black)
  168.  
  169. end
  170.  
  171. function drawSettingScreen()
  172. displayW,displayH=monitor.getSize()
  173.  
  174. -------------Title-------------------
  175. draw_text(16, 6, "Settings", colors.blue, colors.black)
  176.  
  177. monitor.setTextColour((colours.blue))
  178. monitor.setCursorPos(0,7)
  179. monitor.write(string.rep("-", displayW))
  180. monitor.setTextColour((colours.white))
  181. end
  182.  
  183. function checkClickPosition()
  184. displayW,displayH=monitor.getSize()
  185. --if mouseWidth > 20 and mouseWidth < 24 and mouseHeight == 3 then
  186. -- reactor.setActive(true)
  187. --elseif mouseWidth > 24 and mouseWidth < 28 and mouseHeight == 3 then
  188. -- reactor.setActive(false)
  189. if mouseWidth > (displayW - 10) and mouseWidth < displayW and mouseHeight == (displayH - 1) then
  190. if setting then
  191. setting = false
  192. else
  193. setting = true
  194. end
  195. end
  196. sleep(0.5)
  197. end
  198.  
  199.  
  200. function mainMenu()
  201. while true do
  202. displayW,displayH=monitor.getSize()
  203. if displayH == 26 and displayW == 39 then
  204. drawControlScreen()
  205. if setting == true then
  206. drawSettingScreen()
  207. else
  208. drawDisplayScreen()
  209. end
  210. else
  211. print("This program is built for a 4x4 monitor only!")
  212. return
  213. end
  214. sleep(1.0)
  215. end
  216. end
  217.  
  218. function events()
  219. while true do
  220. event,p1,p2,p3 = os.pullEvent()
  221. if event=="monitor_touch" then
  222. mouseWidth = p2 -- sets mouseWidth
  223. mouseHeight = p3 -- and mouseHeight
  224. checkClickPosition() -- this runs our function
  225. end
  226. end
  227. end
  228.  
  229. parallel.waitForAny(mainMenu,events)
Add Comment
Please, Sign In to add comment