diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3cafa32ca..00058b24d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2321,6 +2321,23 @@ static int lib_sMusicPaused(lua_State *L) return 1; } +static int lib_sMusicName(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)) + lua_pushstring(L, S_MusicName()); + else + lua_pushnil(L); + return 1; +} + static int lib_sMusicInfo(lua_State *L) { player_t *player = NULL; @@ -3019,6 +3036,7 @@ static luaL_Reg lib[] = { {"S_MusicType",lib_sMusicType}, {"S_MusicPlaying",lib_sMusicPlaying}, {"S_MusicPaused",lib_sMusicPaused}, + {"S_MusicName",lib_sMusicName}, {"S_MusicInfo",lib_sMusicInfo}, {"S_MusicExists",lib_sMusicExists}, {"S_GetMusicLength",lib_sGetMusicLength},