Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inv = require("component").inventory_controller
- sides = require("sides")
- fuel_side = sides.bottom
- reac_side = sides.front
- switch_side = sides.top
- charge_side = sides.right
- event = require("event")
- r = require("robot")
- Uran_fuel = {"IC2:reactorUraniumQuad", "IC2:reactorUraniumDual"}
- Mox_fuel = {"IC2:reactorMOXQuad", "IC2:reactorMOXDual"}
- function charge()
- local comp = require("computer")
- while comp.energy() < (comp.maxEnergy()/2) do
- local rs = require("component").redstone
- rs.setOutput(charge_side, 15)
- require("term").clear()
- print("Зарядка...")
- require("event").pull(5)
- rs.setOutput(charge_side, 0)
- end
- print("Батарея заряжена")
- return true
- end
- function use(s)
- if s == 1 then r.useUp() else
- if s == 2 then
- r.turnAround()
- r.use()
- r.turnAround()
- else
- if s == 3 then r.use() else
- if s == 4 then
- r.turnRight()
- r.use()
- r.turnRight()
- else
- if s==5 then
- r.turnLeft()
- r.use()
- r.turnLeft()
- else
- r.useDown()
- end
- end
- end
- end
- end
- end
- function clear_self()
- for i=1,16 do
- r.select(i)
- inv.dropIntoSlot(fuel_side, 8)
- end
- r.select(1)
- end
- function reac_off()
- if require("component").redstone.getInput(switch_side) > 0 then
- use(switch_side)
- end
- end
- function reac_on()
- if require("component").redstone.getInput(switch_side) == 0 then
- use(switch_side)
- end
- end
- function clear_reac()
- local sl = inv.getStackInSlot(reac_side, 1)
- if sl ~= nil then
- if sl["maxDamage"] == 0 then
- print("Удаляем отработанное топливо.")
- reac_off()
- inv.suckFromSlot(reac_side, 1)
- inv.suckFromSlot(reac_side, 11)
- inv.suckFromSlot(reac_side, 2)
- inv.suckFromSlot(reac_side, 10)
- event.pull(1)
- clear_self()
- return true
- else
- return false
- end
- else
- return true
- end
- end
- function Fill(fuel)
- if clear_reac() then
- local size = inv.getInventorySize(fuel_side)
- local q = 0
- local d = 0
- for i=1, size do
- local sl = inv.getStackInSlot(fuel_side, i)
- if sl ~= nil then
- if sl["name"] == fuel[1] and sl["size"] >= 2 then
- q = i
- end
- if sl["name"] == fuel[2] and sl["size"] >= 2 then
- d = i
- end
- end
- end
- if q > 0 and d > 0 then
- print("Закладка стержней.", fuel[1])
- r.select(1)
- inv.suckFromSlot(fuel_side, q, 2)
- inv.suckFromSlot(fuel_side, d, 2)
- inv.dropIntoSlot(reac_side, 1, 1)
- inv.dropIntoSlot(reac_side, 11, 1)
- r.select(2)
- inv.dropIntoSlot(reac_side, 2, 1)
- inv.dropIntoSlot(reac_side, 10, 1)
- r.select(1)
- return true
- else
- print("Нет топлива")
- return false
- end
- else
- print("Реактор не отработал топливо.")
- end
- end
- while true do
- event.pull(10)
- if not Fill(Uran_fuel) then
- if Fill(Mox_fuel) then reac_on()
- else
- print("Режим ожидания поставки топлива.")
- end
- else
- reac_on()
- end
- require("term").clear()
- print("Уранит онлайн мин:", require("math").floor(require("computer").uptime()/60))
- charge()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement