From 594bb1b803b79e9315861f2f0245131df0982b2d Mon Sep 17 00:00:00 2001 From: Saurtron Date: Fri, 20 Dec 2024 18:55:47 +0100 Subject: [PATCH] Make GetSoundDevices return a table for each device. - only 'name' field for now. --- rts/Lua/LuaUnsyncedRead.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/rts/Lua/LuaUnsyncedRead.cpp b/rts/Lua/LuaUnsyncedRead.cpp index 3dce046ce8..6fffe44997 100644 --- a/rts/Lua/LuaUnsyncedRead.cpp +++ b/rts/Lua/LuaUnsyncedRead.cpp @@ -3122,10 +3122,20 @@ int LuaUnsyncedRead::GetDrawSeconds(lua_State* L) * @section sound ******************************************************************************/ +/*** Sound device spec + * + * @table soundDeviceSpec + * + * Contains data about a sound device + * + * @string name + */ + + /*** * * @function Spring.GetSoundDevices - * @treturn {[string],...} deviceNames Array of device names + * @treturn {[soundDeviceSpec],...} devices Sound devices */ int LuaUnsyncedRead::GetSoundDevices(lua_State* L) { @@ -3135,8 +3145,14 @@ int LuaUnsyncedRead::GetSoundDevices(lua_State* L) for(int i; i < devices.size(); ++i) { std::string &device = devices[i]; - lua_pushsstring(L, device); - lua_rawseti(L, -2, i); + + lua_createtable(L, 0, 1); { + lua_pushliteral(L, "name"); + lua_pushsstring(L, device); + lua_rawset(L, -3); + } + + lua_rawseti(L, -2, i); } return 1;