if event.type == "program" then mem = {} mem.events = {} mem.orderSize = 5 mem.outputSize = 22 mem.inputName = "Tacit:ironrefab" mem.itemName = "default:iron_lump" mem.orderName = "ironrefab" mem.outputCount = 0 mem.injectCount = 0 mem.state = "checkchest" interrupt(1) end if event.type == "interrupt" then -- if port.a == 0 then -- mem.state = "idle" -- end -- if mem.state == "idle" and mem.outputCount == 0 then -- interrupt(10) -- end port.a = not port.a if mem.state == "checkchest" then digiline_send("chest",{command="get_list"}) end if mem.state == "ordering" then local order = { name=mem.orderName, destination=mem.inputName, item=mem.itemName, stacksize=99, count=mem.orderSize, } digiline_send("drawercontroller", order) mem.state = "waitorder" end if mem.state == "inject" then digiline_send("injector", {name=mem.itemName, count = 99, tags=mem.itemName}) mem.state = "waitoutput" end interrupt(1) end if event.type == "digiline" then if event.channel == "chest" then if event.msg.event and event.msg.event == "inject" then mem.injectCount = mem.injectCount + 1 if mem.injectCount == mem.orderSize then mem.injectCount = 0 mem.state = "inject" end end if not event.msg.event then local emptyCount = 0 local stacks = 0 for k,v in pairs(event.msg) do if v == "" then emptyCount = emptyCount + 1 end if v ~= "" then stacks = stacks + 1 end end if stacks == 0 then mem.state = "ordering" else mem.state = "inject" end end end if event.channel == "detector" then mem.outputCount = mem.outputCount + 1 if mem.outputCount == mem.outputSize then mem.outputCount = 0 mem.state = "checkchest" end end if event.type == "off" then mem.state = "idle" end if event.type == "on" then mem.state = "checkchest" end end