From fbc4fbfd56dbcb2b9604f86e2b5ac44406795529 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Wed, 14 Nov 2018 15:35:16 -0500 Subject: [PATCH] Add S_StopSoundByID to Lua It was brought up to me in another server that character creators might want to have unique engine sounds. While I don't want to support that ourselves, as we have consistent engines for gameplay reasons, this gives people the ability to script around it if they so choose. Plus, it's just generally useful and I'm surprised vanilla hasn't added it, even though they have the function to stop ALL sounds on an object. --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index faeb875bf..1c14093c6 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1824,6 +1824,17 @@ static int lib_sStopSound(lua_State *L) return 0; } +static int lib_sStopSoundByID(lua_State *L) +{ + void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + sfxenum_t sound_id = luaL_checkinteger(L, 2); + NOHUD + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + S_StopSoundByID(origin, sound_id); + return 0; +} + static int lib_sChangeMusic(lua_State *L) { #ifdef MUSICSLOT_COMPATIBILITY @@ -2617,6 +2628,7 @@ static luaL_Reg lib[] = { {"S_StartSound",lib_sStartSound}, {"S_StartSoundAtVolume",lib_sStartSoundAtVolume}, {"S_StopSound",lib_sStopSound}, + {"S_StopSoundByID",lib_sStopSoundByID}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, {"S_StopMusic",lib_sStopMusic},