diff options
author | Zughy <63455151+Zughy@users.noreply.github.com> | 2022-08-12 11:17:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 10:17:37 +0100 |
commit | 8bf1609cccba24e2516ecb98dbf694b91fe697bf (patch) | |
tree | e3fb1a073b7d76a9647386029085678fe942ca50 | |
parent | c8ee755c05ca4410b9b1e816a9244b3cf303d3fe (diff) | |
download | minetest-8bf1609cccba24e2516ecb98dbf694b91fe697bf.tar.xz |
Fix crash when crafting callbacks return strings (#12685)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
-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 |