diff --git a/debug.lua b/debug.lua new file mode 100644 index 0000000..a4628a1 --- /dev/null +++ b/debug.lua @@ -0,0 +1,8 @@ +if event.type == "program" then +mem.events = {} +end + +if event.type == "digiline" then + table.insert(mem.events, event) +end + \ No newline at end of file diff --git a/fabric_nuclear_cells_produtction.lua b/fabric_nuclear_cells_produtction.lua index f75fd50..1e43ecb 100644 --- a/fabric_nuclear_cells_produtction.lua +++ b/fabric_nuclear_cells_produtction.lua @@ -80,7 +80,7 @@ if event.type == "program" then mem={} mem.buttonState = 0 mem.outputCount = 0 -if mem.totalProcessed == nill then +if mem.totalProcessed == nil then mem.totalProcessed = 0 end diff --git a/fabric_refab.lua b/fabric_refab.lua new file mode 100644 index 0000000..793c07d --- /dev/null +++ b/fabric_refab.lua @@ -0,0 +1,92 @@ +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 \ No newline at end of file