diff options
author | Zughy <63455151+Zughy@users.noreply.github.com> | 2022-08-12 11:17:37 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-09-14 13:37:54 +0200 |
commit | 5b9828e0942f78cd0c5fe725383e457291263255 (patch) | |
tree | 291f86bfa394aeea0ac5fd11c490355b00ca0a67 /builtin | |
parent | 96e35585b042222a026f5c0816492672000a2330 (diff) | |
download | minetest-5b9828e0942f78cd0c5fe725383e457291263255.tar.gz minetest-5b9828e0942f78cd0c5fe725383e457291263255.tar.bz2 minetest-5b9828e0942f78cd0c5fe725383e457291263255.zip |
Fix crash when crafting callbacks return strings (#12685)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/register.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/game/register.lua b/builtin/game/register.lua index ee4edabbf..8b6f5b990 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -303,14 +303,16 @@ end function core.on_craft(itemstack, player, old_craft_list, craft_inv) for _, func in ipairs(core.registered_on_crafts) do - itemstack = func(itemstack, player, old_craft_list, craft_inv) or itemstack + -- cast to ItemStack since func() could return a string + itemstack = ItemStack(func(itemstack, player, old_craft_list, craft_inv) or itemstack) end return itemstack end function core.craft_predict(itemstack, player, old_craft_list, craft_inv) for _, func in ipairs(core.registered_craft_predicts) do - itemstack = func(itemstack, player, old_craft_list, craft_inv) or itemstack + -- cast to ItemStack since func() could return a string + itemstack = ItemStack(func(itemstack, player, old_craft_list, craft_inv) or itemstack) end return itemstack end |