From 49325c9c8d7c7db6372357fe79a3a4a1b09b2aad Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Thu, 27 May 2021 15:42:21 +0100 Subject: [PATCH] fix weapon sound selection --- api.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/api.lua b/api.lua index c9da05c..e0d757d 100644 --- a/api.lua +++ b/api.lua @@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi") mobs = { mod = "redo", - version = "20210515", + version = "20210527", intllib = S, invis = minetest.global_exists("invisibility") and invisibility or {} } @@ -2917,14 +2917,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage) -- only play hit sound and show blood effects if damage is 1 or over if damage >= 1 then - local snd - - -- weapon sounds - if weapon_def.sounds then - snd = weapon_def.sounds[random(#weapon_def.sounds)] - else - snd = "default_punch" - end + -- select tool use sound if found, or fallback to default + local snd = weapon_def.sound and weapon_def.sound.use + or "default_punch" minetest.sound_play(snd, {object = self.object, max_hear_distance = 8}, true)