Advertisement
Aest47

Untitled

Aug 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. --Hardware Variables------------------------
  2. local m1 = peripheral.wrap("monitor_25")
  3. local m2 = peripheral.wrap("monitor_3")
  4. local m3 = peripheral.wrap("monitor_23")
  5. local m4 = peripheral.wrap("monitor_22")
  6. local r1 = peripheral.wrap("BigReactors-Reactor_2")
  7. local t1 = peripheral.wrap("BigReactors-Turbine_1")
  8. local t2 = peripheral.wrap("BigReactors-Turbine_0")
  9.  
  10. --Control Button Toggle -------------------
  11. function btn(y,state)
  12.  
  13. if state == "on" then
  14. m1.setCursorPos(18,y)
  15. m1.setBackgroundColor(colors.green)
  16. m1.write(" ON ")
  17. m1.setCursorPos(25,y)
  18. m1.setBackgroundColor(colors.gray)
  19. m1.write(" OFF ")
  20. elseif state == "off" then
  21. m1.setCursorPos(18,y)
  22. m1.setBackgroundColor(colors.gray)
  23. m1.write(" ON ")
  24. m1.setCursorPos(25,y)
  25. m1.setBackgroundColor(colors.red)
  26. m1.write(" OFF ")
  27. end
  28.  
  29. end
  30.  
  31. --Start Program-----------------------------
  32.  
  33. --Control panel initialize
  34. m1.clear()
  35.  
  36. --Reactor
  37. m1.setCursorPos(1,1)
  38. m1.setBackgroundColor(colors.black)
  39. m1.write("Reactor")
  40. btn(1,"on")
  41. r1.setActive(true)
  42.  
  43. --Turbine 1
  44. m1.setCursorPos(1,2)
  45. m1.setBackgroundColor(colors.black)
  46. m1.write("Turbine 1")
  47. btn(2,"on")
  48. t1.setActive(true)
  49.  
  50. --Turbine 2
  51. m1.setCursorPos(1,3)
  52. m1.setBackgroundColor(colors.black)
  53. m1.write("Turbine 2")
  54. btn(3,"on")
  55. t2.setActive(true)
  56.  
  57. --Blast door
  58. m1.setCursorPos(1,5)
  59. m1.setBackgroundColor(colors.black)
  60. m1.write("Blast Door")
  61. btn(5,"off")
  62. redstone.setOutput("top",false)
  63.  
  64. --Program Loop-------------------------------
  65. while true do
  66.  
  67. --Reactor display-----------
  68. m2.clear()
  69.  
  70. m2.setTextColor(colors.white)
  71. m2.setCursorPos(1,1)
  72. m2.write("Reactor")
  73.  
  74. --Status
  75. m2.setCursorPos(15,1)
  76. m2.write("Status:")
  77. m2.setCursorPos(23,1)
  78. if r1.getActive() == true then
  79. m2.setTextColor(colors.green)
  80. m2.write("ONLINE")
  81. btn(1,"on")
  82. else
  83. m2.setTextColor(colors.red)
  84. m2.write("OFFLINE")
  85. btn(1,"off")
  86. end
  87.  
  88. m2.setTextColor(colors.white)
  89.  
  90. --Temp control
  91. local temp = math.floor(r1.getFuelTemperature())
  92. local rods = r1.getControlRodLevel(0)
  93.  
  94. m2.setCursorPos(1,4)
  95. m2.write("Temp:")
  96.  
  97. if temp >= 2000 then
  98. m2.setCursorPos(19,4)
  99. m2.setTextColor(colors.red)
  100. r1.setAllContolRodLevels(rods + 5)
  101. elseif temp >= 1500 then
  102. m2.setCursorPos(19,4)
  103. m2.setTextColor(colors.orange)
  104. r1.setAllContolRodLevels(rods + 1)
  105. elseif temp >= 1000 then
  106. m2.setCursorPos(19,4)
  107. m2.setTextColor(colors.yellow)
  108. r1.setAllContolRodLevels(rods + 1)
  109. elseif (temp < 1000) and (temp > 500) then
  110. m2.setCursorPos(20,4)
  111. m2.setTextColor(colors.green)
  112. elseif temp <= 500 then
  113. m2.setCursorPos(20,4)
  114. m2.setTextColor(colors.white)
  115. r1.setAllControlRodLevels(rods - 1)
  116. end
  117. m2.write(temp)
  118.  
  119. m2.setTextColor(colors.white)
  120. m2.setCursorPos(25,4)
  121. m2.write(" C")
  122.  
  123. --Rods
  124. m2.setCursorPos(1,6)
  125. m2.write("Reactor Output:")
  126. m2.setCursorPos(23,6)
  127. m2.write(100 - rods)
  128. m2.setCursorPos(25,6)
  129. m2.write(" %")
  130.  
  131. --Steam Gen
  132. m2.setCursorPos(1,8)
  133. m2.write("Steam Gen:")
  134. m2.setCursorPos(19,8)
  135. m2.write(math.floor(r1.getHotFluidProducedLastTick()))
  136. m2.setCursorPos(25,8)
  137. m2.write(" mb/t")
  138.  
  139. --Fuel Rate
  140. m2.setCursorPos(1,10)
  141. m2.write("Fuel Rate:")
  142. m2.setCursorPos(19,10)
  143. m2.write(r1.getFuelConsumedLastTick())
  144. m2.setCursorPos(25,10)
  145. m2.write(" mb/t")
  146.  
  147. --Turbine 1 display-----------
  148. m3.clear()
  149.  
  150. m3.setTextColor(colors.white)
  151. m3.setCursorPos(1,1)
  152. m3.write("Turbine 1")
  153.  
  154. m3.setCursorPos(15,1)
  155. m3.write("Status:")
  156.  
  157. m3.setCursorPos(16,3)
  158. m3.write("Coils:")
  159.  
  160. m3.setCursorPos(1,5)
  161. m3.write("Power:")
  162.  
  163. m3.setCursorPos(1,7)
  164. m3.write("Rate:")
  165.  
  166. m3.setCursorPos(1,9)
  167. m3.write("RPM:")
  168.  
  169. m3.setCursorPos(1,11)
  170. m3.write("Steam Flow:")
  171.  
  172. --Turbine 2 display-----------
  173. m4.clear()
  174.  
  175. m4.setTextColor(colors.white)
  176. m4.setCursorPos(1,1)
  177. m4.write("Turbine 2")
  178.  
  179. m4.setCursorPos(15,1)
  180. m4.write("Status:")
  181.  
  182. m4.setCursorPos(16,3)
  183. m4.write("Coils:")
  184.  
  185. m4.setCursorPos(1,5)
  186. m4.write("Power:")
  187.  
  188. m4.setCursorPos(1,7)
  189. m4.write("Rate:")
  190.  
  191. m4.setCursorPos(1,9)
  192. m4.write("RPM:")
  193.  
  194. m4.setCursorPos(1,11)
  195. m4.write("Steam Flow:")
  196.  
  197. --Button Press--------------------------------
  198. os.startTimer(0.5)
  199.  
  200. while true do
  201. local evt = {os.pullEvent()}
  202. if evt[1]=="timer" then
  203. break
  204. elseif evt[1]=="monitor_touch" then
  205. local x,y = evt[3],evt[4]
  206. if evt[2] == "monitor_25" then
  207.  
  208. --ON--
  209. if x>=18 and x<=22 then
  210. btn(y,"on")
  211.  
  212. if y==1 then
  213. r1.setActive(true)
  214. elseif y==2 then
  215. t1.setActive(true)
  216. elseif y==3 then
  217. t2.setActive(true)
  218. elseif y==4 then
  219. --blank line
  220. elseif y==5 then
  221. redstone.setOutput("top",true)
  222. end
  223.  
  224. --OFF--
  225. elseif x>25 and x<=30 then
  226. btn(y,"off")
  227.  
  228. if y==1 then
  229. r1.setActive(false)
  230. elseif y==2 then
  231. t1.setActive(false)
  232. elseif y==3 then
  233. t2.setActive(false)
  234. elseif y==4 then
  235. --blank line
  236. elseif y==5 then
  237. redstone.setOutput("top",false)
  238. end
  239. end
  240. end
  241. end
  242. end
  243. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement