Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lzhs = {1, 5, 8, 12, 17, 19, 24, 31, 36, 38, 43, 47, 50, 54}
- local component = require("component")
- local event = require("event")
- -- local m = component.modem -- get primary modem component
- -- m.open(1488)
- -- print(m.isOpen(1488)) -- true
- -- Send some message.
- -- m.broadcast(1488, "Started.")
- local robot = component.robot
- local sides = require("sides")
- robot.select(2)
- local ic = component.inventory_controller
- -- checking for lapis
- function CheckLapis()
- local slot = 2
- robot.select(2)
- local lapisPassed = false
- while lapisPassed == false do
- local item = ic.getStackInInternalSlot(slot)
- if item then
- if item.size < 64 then
- ic.suckFromSlot(sides.up, 1, 64 - item.size)
- end
- else
- ic.suckFromSlot(sides.up, 1)
- end
- item = ic.getStackInInternalSlot(slot)
- lapisPassed = item.size == 64
- if lapisPassed == false then
- print("Too low amount of lapis!")
- os.sleep(2)
- end
- end
- end
- function wPrint(mes)
- print(mes)
- -- m.broadcast(1488, mes)
- end
- function has_value (tab, val)
- for index, value in ipairs(tab) do
- if value == val then
- return true
- end
- end
- return false
- end
- function CheckLZH(slot)
- local lzhitem = ic.getStackInSlot(sides.forward, slot)
- if lzhitem then
- if lzhitem.damage > 40000 then
- wPrint("LZH at slot ".. tostring(slot).. " is damaged.")
- turnOff()
- RepairLZH(slot)
- turnOn()
- end
- end
- end
- function RepairLZH(slot)
- CheckLapis()
- robot.select(1)
- ic.suckFromSlot(sides.forward, slot)
- component.crafting.craft(1)
- PutLZH(slot)
- end
- function PutLZH(slot)
- ic.dropIntoSlot(sides.forward, slot)
- end
- function GlobalCheckLZHs()
- for i=1, #lzhs do
- CheckLZH(lzhs[i])
- end
- end
- --RepairLZH(1)
- --CheckLZH(1)
- --GlobalCheckLZHs()
- function turnOn()
- component.redstone.setOutput(sides.forward, 15)
- component.redstone.setOutput(sides.back, 15)
- end
- function turnOff()
- component.redstone.setOutput(sides.forward, 0)
- component.redstone.setOutput(sides.back, 0)
- end
- function CheckFuel(slot)
- local fitem = ic.getStackInSlot(sides.forward, slot)
- if fitem then
- if fitem.label == "Quad Fuel Rod (Depleted MOX)" then
- wPrint("Fuel at slot"..tostring(slot).." is depleted.")
- turnOff()
- r.select(1)
- ic.suckFromSlot(sides.forward, slot)
- r.drop(sides.left)
- local item = ic.getStackInSlot(sides.down, 1)
- if item then
- ic.suckFromSlot(sides.down, 1, 1)
- ic.dropIntoSlot(sides.forward, slot)
- end
- end
- end
- end
- function GlobalCheckFuel()
- for i = 1, 54 do
- CheckFuel(i)
- end
- end
- component.redstone.setOutput(sides.right, 15)
- while true do
- turnOn()
- GlobalCheckLZHs()
- -- GlobalCheckFuel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement