summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRealBadAngel <mk@realbadangel.pl>2013-10-07 04:16:31 +0200
committerRealBadAngel <mk@realbadangel.pl>2013-10-07 04:16:31 +0200
commite44deedc532cb4ccf4f3b09369be975ec695af86 (patch)
treeee8d0a82d41a966d1d6ee3937adf50316a060796
parent7fb9cfa3c94c406cbf82d12092588e14eb74c8d5 (diff)
Fix the bug clearing other than default crafting methods.
-rw-r--r--api.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/api.lua b/api.lua
index d026cc0..f090712 100644
--- a/api.lua
+++ b/api.lua
@@ -8,10 +8,16 @@ minetest.after(0.01, function()
def.description and def.description ~= "" then
table.insert(unified_inventory.items_list, name)
local recipes = minetest.get_all_craft_recipes(name)
- unified_inventory.crafts_table[name] = recipes or {}
+ if unified_inventory.crafts_table[name] == nil then
+ unified_inventory.crafts_table[name] = {}
+ end
+ if recipes then
+ for i=1,#recipes,1 do
+ table.insert(unified_inventory.crafts_table[name],recipes[i])
+ end
+ end
end
end
- --print(dump(unified_inventory.crafts_table))
table.sort(unified_inventory.items_list)
unified_inventory.items_list_size = #unified_inventory.items_list
print("Unified Inventory. inventory size: "..#unified_inventory.items_list)
@@ -64,17 +70,17 @@ end
-- register_craft
function unified_inventory.register_craft(options)
- if not options.output then
+ if options.output == nil then
return
end
local itemstack = ItemStack(options.output)
if itemstack:is_empty() then
return
end
- unified_inventory.crafts_table[itemstack:get_name()] =
- unified_inventory.crafts_table[itemstack:get_name()] or {}
-
- table.insert(unified_inventory.crafts_table[itemstack:get_name()], options)
+ if unified_inventory.crafts_table[itemstack:get_name()] == nil then
+ unified_inventory.crafts_table[itemstack:get_name()] = {}
+ end
+ table.insert(unified_inventory.crafts_table[itemstack:get_name()],options)
end
function unified_inventory.register_page(name, def)
@@ -87,9 +93,7 @@ function unified_inventory.register_button(name, def)
unified_inventory.set_inventory_formspec(player, name)
end
end
-
def.name = name
-
table.insert(unified_inventory.buttons, def)
end