Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if (#args < 3) then
- error("Usage: process [inventory side] [output ore direction] [output pulverized direction")
- end
- local inventory = peripheral.wrap(args[1])
- local function yieldOs()
- local loopTimerId = os.startTimer(tickInterval)
- while (true) do
- local event, timerId = os.pullEvent("timer")
- if (timerId == loopTimerId) then
- break
- end
- end
- end
- local function exportItem(item, direction)
- local count = 0
- count = item.size;
- while (cout > 0) do
- local amount = 64
- if (count < amount) then
- amount = count
- end
- local status = interface.exportItem(item.fingerprint, direction, amount)
- count = count - status.size
- if (status.size ~= amount) then
- -- Container space exceeded.
- return
- end
- yieldOs()
- end
- end
- local function mainTick()
- local items = inventory.getAvailableItems()
- local count = 0
- for _, item in pairs(items) do
- if string.sub(item.display_name, -4) == " Ore" then
- exportItem(item, args[2])
- end
- if string.sub(item.display_name, 11) == "Pulverized " then
- exportItem(item, args[3])
- end
- end
- end
- local function main()
- interface = peripheral.wrap(args[1])
- while (true) do
- mainTick()
- yieldOs()
- end
- end
- while true do
- -- Prevent "not attached" error
- pcall(main())
- end
Advertisement
Add Comment
Please, Sign In to add comment