From dfc724fa0669dc20f6c1f374af71b7bc4c237bf1 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 18 Oct 2023 21:44:17 +0200 Subject: [PATCH] Ensure Minetest 5.7.0 compatibility The enforced type checking in Minetest revealed this incorrect API use. --- init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index a257473..540ea39 100644 --- a/init.lua +++ b/init.lua @@ -380,6 +380,10 @@ function throwing.register_bow(name, def) def.strength = 20 end + local throw_sound = def.sound + -- Reserved field by Minetest. Prevent leaking irrelevant data to the registration API + def.sound = nil + def.on_use = function(itemstack, user, pointed_thing) -- Cooldown local meta = itemstack:get_meta() @@ -398,8 +402,8 @@ function throwing.register_bow(name, def) end -- Sound - if def.sound then - minetest.sound_play(def.sound, {to_player=user:get_player_name()}) + if throw_sound then + minetest.sound_play(throw_sound, {to_player=user:get_player_name()}) end meta:set_int("delay", os.time() + (def.delay or 0))