diff --git a/doc/en/7.Audio.md b/doc/en/7.Audio.md index 5b810a34..9322583f 100644 --- a/doc/en/7.Audio.md +++ b/doc/en/7.Audio.md @@ -193,3 +193,13 @@ audio.set_velocity(speakerid: integer, x: number, y: number, z: number) -- also returns 0, if duration is unknown (example: radio) audio.get_duration(speakerid: integer) -> number ``` + +### Other functions + +```lua +-- get current number of alive speakers +audio.count_speakers() -> integer + +-- get current number of playing streams +audio.count_streams() -> integer +``` \ No newline at end of file diff --git a/doc/ru/7.Аудио.md b/doc/ru/7.Аудио.md index 66dfb311..b560b739 100644 --- a/doc/ru/7.Аудио.md +++ b/doc/ru/7.Аудио.md @@ -194,3 +194,12 @@ audio.set_velocity(speakerid: integer, x: number, y: number, z: number) audio.get_duration(speakerid: integer) -> number ``` +### Другие функции + +```lua +-- получить текущее число живых спикеров +audio.count_speakers() -> integer + +-- получить текущее число проигрываемых аудио-потоков +audio.count_streams() -> integer +``` diff --git a/src/logic/scripting/lua/libaudio.cpp b/src/logic/scripting/lua/libaudio.cpp index 1a786692..04401ea5 100644 --- a/src/logic/scripting/lua/libaudio.cpp +++ b/src/logic/scripting/lua/libaudio.cpp @@ -391,6 +391,18 @@ static int l_audio_get_velocity(lua_State* L) { return 0; } +// @brief audio.count_speakers() -> integer +static int l_audio_count_speakers(lua_State* L) { + lua_pushinteger(L, audio::count_speakers()); + return 1; +} + +// @brief audio.count_streams() -> integer +static int l_audio_count_streams(lua_State* L) { + lua_pushinteger(L, audio::count_streams()); + return 1; +} + const luaL_Reg audiolib [] = { {"play_sound", lua_wrap_errors}, {"play_sound_2d", lua_wrap_errors}, @@ -414,5 +426,7 @@ const luaL_Reg audiolib [] = { {"get_duration", lua_wrap_errors}, {"get_position", lua_wrap_errors}, {"get_velocity", lua_wrap_errors}, + {"count_speakers", lua_wrap_errors}, + {"count_streams", lua_wrap_errors}, {NULL, NULL} };