summaryrefslogtreecommitdiff
path: root/autocrafter.lua
diff options
context:
space:
mode:
authorTim <t4im@users.noreply.github.com>2015-01-28 20:56:26 +0100
committerTim <t4im@users.noreply.github.com>2015-01-28 20:56:26 +0100
commit197e433f49edaf39377d0dfa9ce0485030542501 (patch)
treee3b8612b38711b77235f0fd4eea21f4618be2cc6 /autocrafter.lua
parent0cb1eb49dc07749922c0c48158cfc675d3285c82 (diff)
downloadpipeworks-197e433f49edaf39377d0dfa9ce0485030542501.tar
pipeworks-197e433f49edaf39377d0dfa9ce0485030542501.tar.gz
pipeworks-197e433f49edaf39377d0dfa9ce0485030542501.tar.bz2
pipeworks-197e433f49edaf39377d0dfa9ce0485030542501.tar.xz
pipeworks-197e433f49edaf39377d0dfa9ce0485030542501.zip
don't add unknown or groupnamed items to the crafting grid when setting it via the output slot
Diffstat (limited to 'autocrafter.lua')
-rw-r--r--autocrafter.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/autocrafter.lua b/autocrafter.lua
index 6a257d4..8a988f8 100644
--- a/autocrafter.lua
+++ b/autocrafter.lua
@@ -123,6 +123,19 @@ local function after_recipe_change(pos, inventory)
after_inventory_change(pos)
end
+-- clean out unknown items and groups, which would be handled like unknown items in the crafting grid
+-- if minetest supports query by group one day, this might replace them
+-- with a canonical version instead
+local function normalize(item_list)
+ for i = 1, #item_list do
+ local name = item_list[i]
+ if not minetest.registered_items[name] then
+ item_list[i] = ""
+ end
+ end
+ return item_list
+end
+
local function on_output_change(pos, inventory, stack)
if not stack then
inventory:set_list("output", {})
@@ -130,7 +143,7 @@ local function on_output_change(pos, inventory, stack)
else
local input = minetest.get_craft_recipe(stack:get_name())
if not input.items or input.type ~= "normal" then return end
- inventory:set_list("recipe", input.items)
+ inventory:set_list("recipe", normalize(input.items))
-- we'll set the output slot in after_recipe_change to the actual result of the new recipe
end
after_recipe_change(pos, inventory)