diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/common/c_content.cpp | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_server.cpp | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index ca061c454..accbb1a87 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1019,6 +1019,7 @@ void read_server_sound_params(lua_State *L, int index, params.max_hear_distance = BS*getfloatfield_default(L, index, "max_hear_distance", params.max_hear_distance/BS); getboolfield(L, index, "loop", params.loop); + getstringfield(L, index, "exclude_player", params.exclude_player); } } diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 7c083e652..00e849cdf 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -429,7 +429,7 @@ int ModApiServer::l_get_worldpath(lua_State *L) return 1; } -// sound_play(spec, parameters) +// sound_play(spec, parameters, [ephemeral]) int ModApiServer::l_sound_play(lua_State *L) { NO_MAP_LOCK_REQUIRED; @@ -437,8 +437,14 @@ int ModApiServer::l_sound_play(lua_State *L) read_soundspec(L, 1, spec); ServerSoundParams params; read_server_sound_params(L, 2, params); - s32 handle = getServer(L)->playSound(spec, params); - lua_pushinteger(L, handle); + bool ephemeral = lua_gettop(L) > 2 && readParam<bool>(L, 3); + if (ephemeral) { + getServer(L)->playSound(spec, params, true); + lua_pushnil(L); + } else { + s32 handle = getServer(L)->playSound(spec, params); + lua_pushinteger(L, handle); + } return 1; } @@ -446,7 +452,7 @@ int ModApiServer::l_sound_play(lua_State *L) int ModApiServer::l_sound_stop(lua_State *L) { NO_MAP_LOCK_REQUIRED; - int handle = luaL_checkinteger(L, 1); + s32 handle = luaL_checkinteger(L, 1); getServer(L)->stopSound(handle); return 0; } |