Advertisement
koki2000

Reactor control

Oct 16th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 KB | None | 0 0
  1. mon = peripheral.wrap("top")
  2.  
  3. local running = false
  4. local output = true
  5.  
  6. rednet.open("right")
  7.  
  8. function termcls()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. function moncls()
  14. mon.clear()
  15. mon.setCursorPos(1,1)
  16. mon.setTextScale(2)
  17. end
  18.  
  19. function rednet()
  20. id,message = rednet.receive(1)
  21. if id == ID and message == "manual" then
  22. running = false
  23. sleep(1)
  24. print("message")
  25. end
  26. end
  27.  
  28. function drop()
  29. local drop = 0
  30. repeat
  31.   drop = drop + 1  
  32. termcls()
  33. moncls()
  34. print("Kiürítés: 54/"..drop)
  35. mon.write("Kiürítés: 54/"..drop)
  36.    redstone.setBundledOutput("bottom", colors.magenta)
  37. sleep(0.5)
  38.  redstone.setBundledOutput("bottom", 0)
  39. sleep(0.5)
  40. until drop == 55
  41. end
  42.  
  43. function uran()
  44. local uran = 0
  45. repeat
  46.   uran = uran + 1
  47. termcls()
  48. moncls()
  49. print("Urán betöltése: 47/"..uran)
  50. mon.write("Urán betöltése: 47/"..uran)
  51.    redstone.setBundledOutput("bottom", colors.red)
  52. sleep(0.5)
  53.  redstone.setBundledOutput("bottom", 0)
  54. sleep(0.5)
  55. until uran == 47
  56. end
  57.  
  58. function ice()
  59. local ice = 0
  60. repeat
  61.   ice = ice + 1
  62. term.clear()
  63. term.setCursorPos(1,1)
  64. termcls()
  65. moncls()
  66. print("Jég betöltése 22/"..ice)
  67. mon.write("Jég betöltése: 22/"..ice)
  68.    redstone.setBundledOutput("bottom", colors.lime)
  69. sleep(0.5)
  70.  redstone.setBundledOutput("bottom", 0)
  71. sleep(0.5)
  72. until ice== 22
  73. end
  74.  
  75.  
  76. function monitor()
  77. sleep(1)
  78. mon = peripheral.wrap("top")
  79. mon.clear()
  80. mon.setTextScale(2)
  81.  
  82. ctrl = sensors.getController()
  83. data = sensors.getSensors(ctrl)
  84.  
  85. reactorSensor = data[1]
  86.  
  87. data = sensors.getSensorInfo(ctrl,reactorSensor)
  88. sensors.setSensorRange(ctrl,reactorSensor,"2")
  89. data = sensors.getProbes(ctrl,reactorSensor)
  90. reactorProbe = data[2]
  91. data = sensors.getAvailableTargetsforProbe(ctrl,reactorSensor,reactorProbe)
  92. reactorTarget = data[1]
  93. sensors.setTarget(ctrl,reactorSensor,reactorTarget)
  94. data = sensors.getSensorReadingAsDict(ctrl,reactorSensor,reactorTarget,reactorProbe)
  95. mon.setCursorPos(1, 1) mon.write("Reactor TMP: "..data.heat.." C")
  96. mon.setCursorPos(1, 2) mon.write("Reactor EU Out:"..data.output)
  97.  
  98. heat = data.heat
  99. out = data.output
  100.  
  101. data = sensors.getProbes(ctrl,reactorSensor)
  102. euProbe = data[3]
  103. data = sensors.getAvailableTargetsforProbe(ctrl,reactorSensor,euProbe)
  104. mfsuTarget = data[1]
  105. sensors.setTarget(ctrl,reactorSensor,mfsuTarget)
  106. data = sensors.getSensorReadingAsDict(ctrl,reactorSensor,mfsuTarget,euProbe)
  107.  
  108. energy = data.energy
  109. mon.setCursorPos(1, 5) mon.write("MFSU energy:"..energy.."/10M")
  110.  
  111. if heat > 1000 or energy < 512 then
  112. mon.setCursorPos(4, 4) mon.write("Reaktor leállítva")
  113. output = false
  114. running = true
  115. else
  116. mon.setCursorPos(1, 3) mon.write("Hömérséklet rendben")
  117. mon.setCursorPos(4, 4) mon.write("Reaktor elindítva")
  118. end
  119. if out > 1 and out < 99 then
  120. mon.setCursorPos(1, 6)
  121. mon.write("Teljesítmény alacsony")
  122. end
  123. if energy > 9999999 then
  124. redstone.setBundledOutput("bottom", colors.black)
  125. mon.setCursorPos(4, 4) mon.write("Reaktor leállítva")
  126. else
  127. redstone.setBundledOutput("bottom", colors.brown)
  128. mon.setCursorPos(4, 4) mon.write("Reaktor elindítva")
  129. end
  130. if heat > 4500 then
  131. mon.setCursorPos(1, 3) mon.write("Hömérséklet magas")
  132. end
  133. if energy > 9999999 then
  134. mon.setCursorPos(1, 3) mon.write("MFSU Full")
  135. end
  136. end
  137.  
  138.  
  139. while true do
  140.  
  141. if running == true then
  142. redstone.setBundledOutput("bottom", colors.black)
  143. sleep(2)
  144. drop()
  145. sleep(0.1)
  146. uran()
  147. sleep(5)
  148. ice()
  149.    redstone.setBundledOutput("bottom", colors.brown)
  150. running = false
  151. output = true
  152. elseif output == true then
  153. monitor()
  154. sleep(0.1)
  155. else
  156. term.clear()
  157. term.setCursorPos(1,1)
  158. print("debug")
  159. sleep(0.1)
  160. end
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement