From c3d8adb5205aff2d6788c82cb960eac6740445cc Mon Sep 17 00:00:00 2001 From: sfokin Date: Sun, 30 Mar 2025 04:59:28 +0300 Subject: [PATCH] add obsidian maker --- fabric_obsidian_maker.lua | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 fabric_obsidian_maker.lua diff --git a/fabric_obsidian_maker.lua b/fabric_obsidian_maker.lua new file mode 100644 index 0000000..be45e0e --- /dev/null +++ b/fabric_obsidian_maker.lua @@ -0,0 +1,80 @@ +if event.type == "program" then + mem = {} + mem.state = "checkchest" + mem.power = "off" + mem.injectCount = 0 + mem.orderSize = 1 +end + +if event.type == "item" then + if event.item.name == "bucket:bucket_empty" then + mem.state = "checkchest" + return "green" + else + return "blue" + end +end + +if event.type == "interrupt" then + if mem.state == "checkchest" then + digiline_send("uranchest",{command="sort"}) + digiline_send("chest",{command="get_list"}) + end + + if mem.state == "inject" then + digiline_send("obsidianinjector", {name="bucket:bucket_empty", count = 1, tags="bucket:bucket_empty"}) + digiline_send("stoneinjector", {name="moreblocks:cobble_compressed", count = 10, tags="moreblocks:cobble_compressed"}) + mem.state = "waitoutput" + end + + if mem.state == "ordering" then + local order = { + name="obsidianmaker", + destination="Tacit:obsidianmaker", + item="moreblocks:cobble_compressed", + stacksize=90, + count=mem.orderSize, + } + digiline_send("drawercontroller", order) + mem.state = "waitorder" + end + interrupt(5) +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 + if mem.power == "off" then return end + 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 +end + +if event.type == "on" then + mem.power = "on" + mem.state = "checkchest" + interrupt(1) +end + +if event.type == "off" then + mem.power = "off" +end \ No newline at end of file