Fix a bug in crafting where the on_craft callbacks were called incorrectly

This commit is contained in:
KaadmY 2017-05-15 17:51:12 -07:00
parent 90d09fa3e3
commit b991f0e4a3

View File

@ -7,9 +7,7 @@ crafting = {}
-- Callbacks -- Callbacks
crafting.callbacks = { crafting.callbacks = {}
on_craft = {},
}
-- Array of registered craft recipes -- Array of registered craft recipes
@ -112,6 +110,10 @@ function crafting.get_crafts(filter)
end end
function crafting.register_on_craft(func) function crafting.register_on_craft(func)
if not crafting.callbacks.on_craft then
crafting.callbacks.on_craft = {}
end
table.insert(crafting.callbacks.on_craft, func) table.insert(crafting.callbacks.on_craft, func)
end end
@ -213,7 +215,7 @@ function crafting.craft(player, wanted, wanted_count, output, items)
end end
for _, func in ipairs(crafting.callbacks.on_craft) do for _, func in ipairs(crafting.callbacks.on_craft) do
for i = 1, output:get_count() do for i = 1, (craftdef.output:get_count() * craft_count) do
func(output, player) func(output, player)
end end
end end