From 976dd379ca80c1dc5f025065c7a8fd8d1bcece4d Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 23 Oct 2020 16:33:39 +0200 Subject: [PATCH] Autocrafter: Add register function for uncraftable items --- basic_machines/autocrafter.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/basic_machines/autocrafter.lua b/basic_machines/autocrafter.lua index 5074af5..9bfc575 100644 --- a/basic_machines/autocrafter.lua +++ b/basic_machines/autocrafter.lua @@ -28,6 +28,13 @@ local STANDBY_TICKS = 3 local COUNTDOWN_TICKS = 4 local CYCLE_TIME = 4 +local UncraftableItems = {} + +-- Add all nodes/items which should not be crafted with the autocrafter +function techage.register_uncraftable_items(item_name) + UncraftableItems[item_name] = true +end + local function formspec(self, pos, nvm) return "size[8,9.2]".. default.gui_bg.. @@ -71,6 +78,12 @@ local function get_craft(pos, inventory, hash) local recipe = inventory:get_list("recipe") local output, decremented_input = minetest.get_craft_result( {method = "normal", width = 3, items = recipe}) + + -- check if registered item + if UncraftableItems[output.item:get_name()] then + output.item = ItemStack() + end + craft = {recipe = recipe, consumption = count_index(recipe), output = output, decremented_input = decremented_input} autocrafterCache[hash] = craft