From b991f0e4a3a62138f60cea08fd745432aace99dd Mon Sep 17 00:00:00 2001 From: KaadmY Date: Mon, 15 May 2017 17:51:12 -0700 Subject: [PATCH] Fix a bug in crafting where the on_craft callbacks were called incorrectly --- mods/crafting/api.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mods/crafting/api.lua b/mods/crafting/api.lua index 1b03a1a..8a4091f 100644 --- a/mods/crafting/api.lua +++ b/mods/crafting/api.lua @@ -7,9 +7,7 @@ crafting = {} -- Callbacks -crafting.callbacks = { - on_craft = {}, -} +crafting.callbacks = {} -- Array of registered craft recipes @@ -112,6 +110,10 @@ function crafting.get_crafts(filter) end 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) end @@ -213,7 +215,7 @@ function crafting.craft(player, wanted, wanted_count, output, items) end 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) end end