From 341f92f1184a1e66566adf0bb72bb2ac41e11b03 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sat, 3 Aug 2024 11:56:52 +0100 Subject: [PATCH] harden sound_play checks --- api.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api.lua b/api.lua index f20c8f7..71da25c 100644 --- a/api.lua +++ b/api.lua @@ -5065,7 +5065,7 @@ local old_sound_play = minetest.sound_play minetest.sound_play = function(spec, param, eph) - local op_params = {} + local op_params = {} ; param = param or {} -- store sound position if param.pos then @@ -5076,6 +5076,11 @@ minetest.sound_play = function(spec, param, eph) op_params.pos = minetest.get_player_by_name(param.to_player):get_pos() end + -- if no position found use default function + if not op_params.pos then + return old_sound_play(spec, param, eph) + end + -- store sound name and gain if type(spec) == "string" then op_params.sound = spec