mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-12-25 18:30:23 +01:00
don't add unknown or groupnamed items to the crafting grid when setting it via the output slot
This commit is contained in:
parent
0cb1eb49dc
commit
197e433f49
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user