Advertisement
_GameDoctor_

greactor1

Mar 12th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 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.  
  75. gpu.setResolution(18,8)
  76. gpu.setBackground(0x000000)
  77. gpu.fill(1, 1, w, h, " ")
  78. gpu.setForeground(0xDC143C)
  79. gpu.set(1,1,"   Реактор 1      ")
  80. gpu.setForeground(0xFF00FF)
  81. gpu.set(1,2,"Всего:   "..math.floor(capacity).." ")
  82. gpu.setForeground(0xFFFFFF)
  83.  
  84. while true do
  85.   stored = math.floor(bat.getStored())
  86.   gpu.setForeground(0xFF00FF)
  87.   gpu.set(1,3,"Энергия: "..stored.." ")
  88.   procent = math.floor(stored/capacity*100)
  89. gpu.setForeground(0xFF00FF)
  90.   gpu.set(1,4,"Хранится:  "..procent.." % ")
  91.   gpu.setForeground(0xFF00FF)
  92.   gpu.set(1,5,"EU/T:    "..math.floor(reactor.getReactorEUOutput()).." ")
  93.   gpu.setForeground(0xFFFFFF)
  94.   if reactor.getHeat() > heat then
  95.     red.setOutput(sideRed, 0)
  96.     gpu.setForeground(0xFF0000)
  97.     gpu.set(1,6,"Перегрев реактора")
  98.     gpu.set(1,7,"Реактор оставновлен")
  99.     gpu.setForeground(0xFFFFFF)
  100.     computer.beep(500, 1)
  101.     os.sleep(3)
  102.   else
  103.   gpu.setForeground(0xFF00FF)
  104.     gpu.set(1,6,"Нагрев:  "..math.floor(reactor.getHeat()).."         ")
  105.     gpu.setForeground(0xFFFFFF)
  106.     if procent < 98 then
  107.       red.setOutput(sideRed, 15)
  108.     elseif procent == 100 then
  109.       red.setOutput(sideRed, 0)
  110.       gpu.setForeground(0xFF0000)
  111.       gpu.set(1,7,"Реактор остановлен       ")
  112.       gpu.setForeground(0x20AFFF)
  113.       gpu.set(1,8," -= by GameDoctor =-     ")
  114.         gpu.setForeground(0xFFFFFF)
  115.     end
  116.   end
  117.   if reactor.producesEnergy() and reactor.getReactorEUOutput() == 0 then
  118.     noFuel = noFuel + 1
  119.   else
  120.     noFuel = 0
  121.   end
  122.   if noFuel >= 3 then
  123.     gpu.setForeground(0xFF0000)
  124.     gpu.set(1,7,"Топливо не найдено     ")
  125.     gpu.setForeground(0xFFFFFF)
  126.     computer.beep(500, 1)
  127.     os.sleep(3)
  128.   elseif reactor.producesEnergy() then
  129.     gpu.setForeground(0x00FF00)
  130.     gpu.set(1,7,"Реактор активен   ")
  131.     gpu.setForeground(0x20AFFF)
  132.     gpu.set(1,8," -= GameDoctor =-     ")
  133.     gpu.setForeground(0xFFFFFF)
  134.    
  135.   end
  136.   local e = event.pull(1)
  137.   if e == "key_down" then
  138.     red.setOutput(sideRed, 0)
  139.     gpu.setResolution(w, h)
  140.     gpu.fill(1, 1, w, h, " ")
  141.     print("Программа завершена.")
  142.     os.sleep(1)
  143.     if reactor.producesEnergy() then
  144.       print("ВНИМАНИЕ: Реактор всё ещё активен.")
  145.       computer.beep(500, 1)
  146.       os.sleep(1)
  147.     else
  148.  
  149.     end
  150.     os.exit()
  151.   end
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement