Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local offReac = 9850
- local perDamage = 77
- local perDamageS = 1000
- local computer = require("computer")
- local com = require("component")
- local event = require("event")
- local gpu = com.gpu
- local slotReac = {}
- local slotSter = {}
- local per,pers,noFuel,toChest,toReac = 0,0,1,1
- local vr,data1,sideReac,sideInv,sideRed,sideinterface
- local w,h = gpu.getResolution()
- if not com.isAvailable("reactor_chamber") then
- print("для работы нужен адаптер")
- os.exit()
- end
- local reactor = com.reactor_chamber
- if not com.isAvailable("transposer") then
- print("для работы нужен транспозер")
- os.exit()
- end
- local tr = com.transposer
- if not com.isAvailable("redstone") then
- print("для работы нужен контроллер красного камня")
- os.exit()
- end
- local red = com.redstone
- if reactor.producesEnergy() then
- print("\n".."остановите реактор !")
- for i=0,5 do
- if red.getOutput(i) > 0 then
- red.setOutput(i, 0)
- end
- end
- os.exit()
- end
- if reactor.getHeat() > offReac then
- print("\n".."перегрев реактора !")
- os.exit()
- end
- print("поиск реактора и сундука")
- for i=0,5 do
- vr = tr.getInventoryName(i)
- if vr then
- if vr == "ic2:te" then
- print("реактор в стороне: "..i)
- sideReac = i
- end
- local chest = string.find(vr,"hest")
- if chest then
- print("сундук в стороне: "..i)
- sideInv = i
- end
- local interface = string.find(vr,"interface")
- if interface then
- print("interface в стороне: "..i)
- sideinterface = i
- end
- end
- end
- if not sideReac then
- print("\n".."камера реактора не найдена")
- os.exit()
- end
- if not sideInv then
- print("\n".."сундук не найден")
- os.exit()
- end
- if not sideinterface then
- print("\n".."interface не найден")
- os.exit()
- end
- local slotsReac = tr.getInventorySize(sideReac)
- local slotsInv = tr.getInventorySize(sideInv)
- local slotsinterface = tr.getInventorySize(sideinterface)
- print("сохранение расположения стержней")
- local data = tr.getAllStacks(sideReac).getAll()
- for i=0, slotsReac+1 do
- if data[i] and (data[i].name == 'ic2:quad_uranium_fuel_rod' or data[i].name == "ic2:quad_mox_fuel_rod") then
- pers = math.ceil(100*data[i].damage/10000)
- print("слот: "..(i).." износ: "..pers.." %")
- if pers >= perDamageS then
- print("\n".."замените стержень в слоте: "..(i))
- os.exit()
- end
- slotSter[#slotSter+1] = i
- end
- end
- print("сохранение расположения конденсаторов")
- local data = tr.getAllStacks(sideReac).getAll()
- for i=0, slotsReac+1 do
- if data[i] and (data[i].name == 'ic2:lzh_condensator' or data[i].name == "ic2:lzh_condensator") then
- per = math.ceil(100*data[i].damage/100000)
- print("слот: "..(i).." износ: "..per.." %")
- if per >= perDamage then
- print("\n".."замените конденсатор в слоте: "..(i))
- os.exit()
- end
- slotReac[#slotReac+1] = i
- end
- end
- print("пробный запуск")
- for i=0,5 do
- red.setOutput(i, 15)
- if reactor.producesEnergy() then
- sideRed = i
- red.setOutput(sideRed, 0)
- print("редстоун в стороне: "..sideRed)
- break
- else
- red.setOutput(i, 0)
- end
- if i == 5 then
- print("\n".."реактор не запускается")
- os.exit()
- end
- end
- print("настройка завершена".."\n".."старт...")
- os.sleep(2)
- local function gui()
- gpu.setResolution(28,15)
- gpu.setBackground(0x000000)
- gpu.fill(1,1,28,15," ")
- gpu.setForeground(0x669999)
- gpu.set(1,1,"┌──────────────────────────┐")
- gpu.set(1,2,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,3,"│──────────────────────────│")
- gpu.set(1,4,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,5,"│──────────────────────────│")
- gpu.set(1,6,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,7,"│──────────────────────────│")
- gpu.set(1,8,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,9,"│──────────────────────────│")
- gpu.set(1,10,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,11,"│──────────────────────────│")
- gpu.set(1,12,"│ │ │ │ │ │ │ │ │ │")
- gpu.set(1,13,"└──────────────────────────┘")
- end
- local xy = {
- {"2","2"},{"5","2"},{"8","2"},{"11","2"},{"14","2"},{"17","2"},{"20","2"},{"23","2"},{"26","2"},
- {"2","4"},{"5","4"},{"8","4"},{"11","4"},{"14","4"},{"17","4"},{"20","4"},{"23","4"},{"26","4"},
- {"2","6"},{"5","6"},{"8","6"},{"11","6"},{"14","6"},{"17","6"},{"20","6"},{"23","6"},{"26","6"},
- {"2","8"},{"5","8"},{"8","8"},{"11","8"},{"14","8"},{"17","8"},{"20","8"},{"23","8"},{"26","8"},
- {"2","10"},{"5","10"},{"8","10"},{"11","10"},{"14","10"},{"17","10"},{"20","10"},{"23","10"},{"26","10"},
- {"2","12"},{"5","12"},{"8","12"},{"11","12"},{"14","12"},{"17","12"},{"20","12"},{"23","12"},{"26","12"},
- }
- local function circuitCheck()
- local data = tr.getAllStacks(sideReac).getAll()
- local sh = 0
- for i=1,#slotReac do
- if data[slotReac[i]].damage then
- sh = sh + 1
- end
- end
- if sh == #slotReac then
- return true
- else
- return false
- end
- end
- local function stop()
- red.setOutput(sideRed, 0)
- gpu.setResolution(w, h)
- gpu.setBackground(0x000000)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(1, 1, w, h, " ")
- print("программа завершена")
- os.sleep(1)
- if reactor.producesEnergy() then
- print("ВНИМАНИЕ реактор по прежнему активен !!!")
- else
- print("реактор остановлен")
- end
- os.exit()
- end
- gui()
- gpu.setForeground(0xFF9900)
- gpu.set(1,14," для завершения нажмите E ")
- while true do
- local data = tr.getAllStacks(sideReac).getAll()
- for i=1,#slotReac do
- if data[slotReac[i]].damage then
- per = math.ceil(100*data[slotReac[i]].damage/100000)
- gpu.setForeground(0xFF9900)
- gpu.set(tonumber(xy[slotReac[i]][1]),tonumber(xy[slotReac[i]][2]),tostring(per))
- else
- per = 0
- end
- if per == 100 then
- red.setOutput(sideRed, 0)
- gpu.setForeground(0xFF0000)
- gpu.set(1,14," снизте % замены конденсат. ")
- gpu.set(1,15," реактор остановлен ")
- event.pull("key_down")
- stop()
- end
- if computer.energy() <=400 then
- print("В Системе Кончился Лазурит! Реактор Остановлен")
- stop()
- end
- if per >= perDamage or per == 0 then
- red.setOutput(sideRed, 0)
- gpu.setForeground(0xFF9900)
- gpu.set(1,15," замена конденсаторов ")
- os.sleep(0.2)
- toChest = tr.transferItem(sideReac, sideInv, 1, slotReac[i])
- gpu.setForeground(0xFF0000)
- gpu.set(tonumber(xy[slotReac[i]][1]),tonumber(xy[slotReac[i]][2]),"██")
- data1 = tr.getAllStacks(sideInv).getAll()
- for i1=0,slotsInv do
- if data1[i1] and (data1[i1].name == "ic2:lzh_condensator" or data1[i1].name == "ic2:lzh_condensator") and data1[i1].damage < 100 then
- toReac = tr.transferItem(sideInv, sideReac, 1, i1, slotReac[i])
- gpu.setForeground(0x00FF00)
- gpu.set(tonumber(xy[slotReac[i]][1]),tonumber(xy[slotReac[i]][2]),"██")
- break
- end
- end
- end
- end
- -- получаем все слоты реактора
- local data = tr.getAllStacks(sideReac).getAll()
- -- проходим все слоты
- for i=1,#slotSter do
- -- если в слоте хуйня
- if data[slotSter[i]].name == "ic2:nuclear" then
- -- убираем в сундук
- tr.transferItem(sideReac, sideinterface, 1, slotSter[i])
- -- получаем инвентарь интерфейса
- data1 = tr.getAllStacks(sideinterface).getAll()
- -- проходим все ячейки
- for i1=0,slotsinterface do
- -- если в ячейке топливо
- if data1[i1] and data1[i1].name == "ic2:quad_mox_fuel_rod" then
- -- кладем на место старого
- tr.transferItem(sideinterface, sideReac, 1, i1, slotSter[i])
- break
- end
- end
- end
- end
- gpu.setForeground(0xFF0000)
- if reactor.getHeat() > offReac then
- red.setOutput(sideRed, 0)
- gpu.set(1,15," перегрев реактора ! ")
- elseif not circuitCheck() then
- gpu.set(1,15," нет целых конденсаторов ! ")
- elseif toChest == 0 and toReac == 0 then
- gpu.set(1,15," в сундуке нет места ! ")
- elseif noFuel >= 5 then
- gpu.set(1,15," нет топлива ! ")
- else
- red.setOutput(sideRed, 15)
- if not reactor.producesEnergy() then
- gpu.set(1,15," реактор не запускается ! ")
- else
- gpu.setForeground(0x00FF00)
- gpu.set(1,15," реактор работает ")
- end
- end
- local e = {event.pull(0.7,"key_down")}
- if e[4] == 18 or e[4] == 20 then
- stop()
- end
- if reactor.producesEnergy() and reactor.getReactorEUOutput() == 0 then
- noFuel = noFuel + 1
- else
- noFuel = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement