Skip to content

Commit

Permalink
Make GetSoundDevices return a table for each device.
Browse files Browse the repository at this point in the history
- only 'name' field for now.
  • Loading branch information
saurtron committed Dec 20, 2024
1 parent fb765a6 commit 594bb1b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions rts/Lua/LuaUnsyncedRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 594bb1b

Please sign in to comment.