diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f7a0a599..6a878425 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -720,13 +720,8 @@ static int lib_pRestoreMusic(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); else if (P_IsLocalPlayer(player)) - { P_RestoreMusic(player); - lua_pushboolean(L, true); - } - else - lua_pushnil(L); - return 1; + return 0; } static int lib_pSpawnShieldOrb(lua_State *L) @@ -1780,13 +1775,8 @@ static int lib_sChangeMusic(lua_State *L) fadeinms = (UINT32)luaL_optinteger(L, 7, 0); if (!player || P_IsLocalPlayer(player)) - { S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms); - lua_pushboolean(L, true); - } - else - lua_pushnil(L); - return 1; + return 0; } static int lib_sSpeedMusic(lua_State *L) @@ -1802,10 +1792,23 @@ static int lib_sSpeedMusic(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!player || P_IsLocalPlayer(player)) - lua_pushboolean(L, S_SpeedMusic(speed)); - else - lua_pushnil(L); - return 1; + S_SpeedMusic(speed); + return 0; +} + +static int lib_sStopMusic(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + S_StopMusic(); + return 0; } static int lib_sOriginPlaying(lua_State *L) @@ -2130,6 +2133,7 @@ static luaL_Reg lib[] = { {"S_StopSound",lib_sStopSound}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, + {"S_StopMusic",lib_sStopMusic}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 74a6b5e7..53e0a7d8 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -43,7 +43,6 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, - hook_MusicChange, hook_MAX // last hook }; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index dff2b8f4..eadd0153 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -54,7 +54,6 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", - "MusicChange", NULL };