Advertisement
_GameDoctor_

greactor1_neww

Aug 5th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. local heat = 130
  2.  
  3. local com = require("component")
  4. local computer = require("computer")
  5. local event = require("event")
  6. local gpu = com.gpu
  7. local colors = require("colors")
  8. local w, h = gpu.getResolution()
  9. local noFuel,sideRed = 0,nil
  10.  
  11.  
  12. print("By GameDoctor")
  13. if com.isAvailable("reactor") then
  14. reactor = com.reactor
  15. elseif com.isAvailable("reactor_chamber") then
  16. reactor = com.reactor_chamber
  17. else
  18. print("Реактор не был обнаружен.")
  19. os.exit()
  20. end
  21.  
  22. if reactor.getHeat() > heat then
  23. print("Реактор не может быть запущен, т.к уровень нагрева выше 1%")
  24. os.exit()
  25. end
  26.  
  27. if com.isAvailable("mfsu") then
  28. bat = com.mfsu
  29. print("подключен мфсу")
  30. elseif com.isAvailable("mfe") then
  31. bat = com.mfe
  32. print("подключен мфэ")
  33. elseif com.isAvailable("cesu") then
  34. bat = com.cesu
  35. print("подключен мэх")
  36. elseif com.isAvailable("asfu") then
  37. bat = com.asfu
  38. print("подключен ЭХПФ")
  39. elseif com.isAvailable("cesu") then
  40. bat = com.cesu
  41. print("подключен мэх")
  42. elseif com.isAvailable("batbox") then
  43. bat = com.batbox
  44. print("подключен batbox")
  45. else
  46. print("батарея не найдена")
  47. os.exit()
  48. end
  49. local capacity = bat.getCapacity()
  50.  
  51. if not com.isAvailable("redstone") then
  52. print("Ошибка: для работы требуется контроллер красного камня!")
  53. os.exit()
  54. end
  55. local red = com.redstone
  56.  
  57. print("Пробный запуск...")
  58. for i=0,5 do
  59. red.setOutput(i, 15)
  60. if reactor.producesEnergy() then
  61. sideRed = i
  62. red.setOutput(sideRed, 0)
  63. print("Редстоун в стороне: "..sideRed)
  64. os.sleep(1)
  65. break
  66. else
  67. red.setOutput(i, 0)
  68. end
  69. if i == 5 then
  70. print("\n".."Реактор не запускается.")
  71. os.exit()
  72. end
  73. end
  74. gpu.setBackground(0x000000)
  75. gpu.setForeground(0xFFFFFF)
  76. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  77. print("10")
  78. os.sleep(1)
  79. gpu.setBackground(0x000000)
  80. gpu.setForeground(0xFFFFFF)
  81. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  82. print("9")
  83. os.sleep(1)
  84. gpu.setBackground(0x000000)
  85. gpu.setForeground(0xFFFFFF)
  86. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  87. print("8")
  88. os.sleep(1)
  89. gpu.setBackground(0x000000)
  90. gpu.setForeground(0xFFFFFF)
  91. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  92. print("7")
  93. os.sleep(1)
  94. gpu.setBackground(0x000000)
  95. gpu.setForeground(0xFFFFFF)
  96. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  97. print("6")
  98. os.sleep(1)
  99. gpu.setBackground(0x000000)
  100. gpu.setForeground(0xFFFFFF)
  101. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  102. print("5")
  103. os.sleep(1)
  104. gpu.setBackground(0x000000)
  105. gpu.setForeground(0xFFFFFF)
  106. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  107. print("4")
  108. os.sleep(1)
  109. gpu.setBackground(0x000000)
  110. gpu.setForeground(0xFFFFFF)
  111. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  112. print("3")
  113. os.sleep(1)
  114. gpu.setBackground(0x000000)
  115. gpu.setForeground(0xFFFFFF)
  116. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  117. print("2")
  118. os.sleep(1)
  119. gpu.setBackground(0x000000)
  120. gpu.setForeground(0xFFFFFF)
  121. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  122. print("1")
  123. os.sleep(1)
  124.  
  125. gpu.setResolution(18,8)
  126. gpu.setBackground(0x000000)
  127. gpu.fill(1, 1, w, h, " ")
  128. gpu.setForeground(0xDC143C)
  129. gpu.set(1,1," Реактор 1 ")
  130. gpu.setForeground(0xFF00FF)
  131. gpu.set(1,2,"Всего: "..math.floor(capacity).." ")
  132. gpu.setForeground(0xFFFFFF)
  133.  
  134. while true do
  135. stored = math.floor(bat.getStored())
  136. gpu.setForeground(0xFF00FF)
  137. gpu.set(1,3,"Энергия: "..stored.." ")
  138. procent = math.floor(stored/capacity*100)
  139. gpu.setForeground(0xFF00FF)
  140. gpu.set(1,4,"Хранится: "..procent.." % ")
  141. gpu.setForeground(0xFF00FF)
  142. gpu.set(1,5,"EU/T: "..math.floor(reactor.getReactorEUOutput()).." ")
  143. gpu.setForeground(0xFFFFFF)
  144. if reactor.getHeat() > heat then
  145. red.setOutput(sideRed, 0)
  146. gpu.setForeground(0xFF0000)
  147. gpu.set(1,6,"Перегрев реактора")
  148. gpu.set(1,7,"Реактор оставновлен")
  149. gpu.setForeground(0xFFFFFF)
  150. computer.beep(500, 1)
  151. os.sleep(3)
  152. else
  153. gpu.setForeground(0xFF00FF)
  154. gpu.set(1,6,"Нагрев: "..math.floor(reactor.getHeat()).." ")
  155. gpu.setForeground(0xFFFFFF)
  156. if procent < 98 then
  157. red.setOutput(sideRed, 15)
  158. elseif procent == 100 then
  159. red.setOutput(sideRed, 0)
  160. gpu.setForeground(0xFF0000)
  161. gpu.set(1,7,"Реактор остановлен ")
  162. gpu.setForeground(0x20AFFF)
  163. gpu.set(1,8," -= by GameDoctor =- ")
  164. gpu.setForeground(0xFFFFFF)
  165. end
  166. end
  167. if reactor.producesEnergy() and reactor.getReactorEUOutput() == 0 then
  168. noFuel = noFuel + 1
  169. else
  170. noFuel = 0
  171. end
  172. if noFuel >= 3 then
  173. gpu.setForeground(0xFF0000)
  174. gpu.set(1,7,"Топливо не найдено ")
  175. gpu.setForeground(0xFFFFFF)
  176. computer.beep(500, 1)
  177. os.sleep(3)
  178. elseif reactor.producesEnergy() then
  179. gpu.setForeground(0x00FF00)
  180. gpu.set(1,7,"Реактор активен ")
  181. gpu.setForeground(0x20AFFF)
  182. gpu.set(1,8," -= GameDoctor =- ")
  183. gpu.setForeground(0xFFFFFF)
  184.  
  185. end
  186. local e = event.pull(1)
  187. if e == "key_down" then
  188. red.setOutput(sideRed, 0)
  189. gpu.setResolution(w, h)
  190. gpu.fill(1, 1, w, h, " ")
  191. print("Программа завершена.")
  192. os.sleep(1)
  193. if reactor.producesEnergy() then
  194. print("ВНИМАНИЕ: Реактор всё ещё активен.")
  195. computer.beep(500, 1)
  196. os.sleep(1)
  197. else
  198.  
  199. end
  200. os.exit()
  201. end
  202. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement