Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reactor = component.proxy(component.list("warpdriveEnanReactorCore")())
- cell = component.proxy(component.list("capacitor_bank")())
- gpu = component.proxy(component.list("gpu")())
- config = {
- instability = 90,
- instability_critical = 95,
- energy = 65,
- energy_critical = 95,
- energy_out = 95000000,
- energy_low_out = 1000000,
- slow_out = false,
- can_work = true,
- exit = false
- }
- for redstone_card in pairs(component.list("redstone")) do
- redstone = component.proxy(redstone_card)
- redstone.setWakeThreshold(1)
- end
- function stop()
- gpu.set(18, 6, "Выключение... ")
- reactor.release(true)
- reactor.enable(false)
- config.can_work = false
- end
- function listener(...)
- evt, _, _, code = computer.pullSignal(...)
- if evt == "key_down" and code == 41 then
- computer.beep()
- stop()
- config.exit = true
- elseif not config.can_work and reactor.energy() == 0 and not state then
- gpu.set(18, 6, "Выключен ")
- reactor.release(false)
- if not config.exit then
- config.can_work = true
- else
- if redstone then
- redstone.setWakeThreshold(0)
- end
- computer.shutdown()
- end
- end
- end
- function sleep(timeout)
- deadline = computer.uptime() + timeout
- repeat
- listener(deadline - computer.uptime())
- until computer.uptime() >= deadline
- end
- function check_instability()
- if math.max(reactor.instability()) > config.instability_critical then
- stop()
- end
- end
- function start()
- check_instability()
- gpu.set(18, 6, "Работает... ")
- reactor.enable(false)
- reactor.enable(true)
- reactor.instabilityTarget(config.instability)
- reactor.stabilizerEnergy(10000)
- reactor.releaseAbove(config.energy_out)
- end
- function drawStat()
- gpu.set(17, 1, math.floor(math.max(reactor.instability())) .. "% ")
- if config.slow_out then
- slow_out = "Да "
- else
- slow_out = "Нет"
- end
- gpu.set(19, 2, slow_out)
- gpu.set(17, 3, math.floor(cell_energy) .. "% ")
- gpu.set(21, 4, math.floor(cell.getAverageInputPerTick()) .. " ")
- gpu.set(17, 5, math.floor(reactor_energy) .. " ")
- end
- function reactor_ctrl()
- check_instability()
- _, state = reactor.state()
- reactor_energy = reactor.energy()
- cell_energy = cell.getEnergyStored() / (cell.getMaxEnergyStored() / 100)
- drawStat()
- if config.can_work then
- if cell_energy >= config.energy_critical and state then
- stop()
- elseif cell_energy < config.energy_critical and not state then
- start()
- elseif cell_energy > config.energy then
- reactor.releaseAbove(config.energy_low_out)
- if not config.slow_out then
- config.slow_out = true
- end
- elseif cell_energy < config.energy then
- reactor.releaseAbove(config.energy_out)
- if config.slow_out then
- config.slow_out = false
- end
- end
- end
- end
- gpu.bind(component.proxy(component.list("screen")()).address)
- gpu.setResolution(32, 16)
- gpu.set(1, 1, "Нестабильность:")
- gpu.set(1, 2, "Пониженный вывод:")
- gpu.set(1, 3, "Заряд батарей:")
- gpu.set(1, 4, "Выход энергии RF/T:")
- gpu.set(1, 5, "Заряд реактора:")
- gpu.set(1, 6, "Статус реактора:")
- start()
- while true do
- sleep(1)
- reactor_ctrl()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement