diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-07-12 14:40:54 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-07-12 14:40:54 +1000 |
| commit | f78de39a750d58bfe883a789aa6cc4b0a5d9b9e7 (patch) | |
| tree | bd7c20afd43745a0648aa36b83f8414f0fe5ba42 /src/tangara/lua | |
| parent | a3eb2dd9dc2399ce9c22cd3b07f482f080976440 (diff) | |
| download | tangara-fw-f78de39a750d58bfe883a789aa6cc4b0a5d9b9e7.tar.gz | |
Give Bluetooth settings a bit of a refresh
It's now a bit more responsive to stuff happening, gives you more information, and remembers your previously paired devices for faster switching between them.
Diffstat (limited to 'src/tangara/lua')
| -rw-r--r-- | src/tangara/lua/property.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/tangara/lua/property.cpp b/src/tangara/lua/property.cpp index 7b4f0b97..1be1fd2d 100644 --- a/src/tangara/lua/property.cpp +++ b/src/tangara/lua/property.cpp @@ -371,33 +371,34 @@ auto popRichType(lua_State* L) -> LuaValue { } auto Property::popValue(lua_State& s) -> bool { - LuaValue new_val; - switch (lua_type(&s, 2)) { - case LUA_TNIL: - new_val = std::monostate{}; - break; - case LUA_TNUMBER: - if (lua_isinteger(&s, 2)) { - new_val = lua_tointeger(&s, 2); - } else { - new_val = static_cast<lua_Integer>(std::round(lua_tonumber(&s, 2))); - } - break; - case LUA_TBOOLEAN: - new_val = static_cast<bool>(lua_toboolean(&s, 2)); - break; - case LUA_TSTRING: - new_val = lua_tostring(&s, 2); - break; - default: - if (lua_istable(&s, 2)) { - new_val = popRichType(&s); - if (std::holds_alternative<std::monostate>(new_val)) { + LuaValue new_val{std::monostate{}}; + if (lua_gettop(&s) >= 2) { + switch (lua_type(&s, 2)) { + case LUA_TNIL: + break; + case LUA_TNUMBER: + if (lua_isinteger(&s, 2)) { + new_val = lua_tointeger(&s, 2); + } else { + new_val = static_cast<lua_Integer>(std::round(lua_tonumber(&s, 2))); + } + break; + case LUA_TBOOLEAN: + new_val = static_cast<bool>(lua_toboolean(&s, 2)); + break; + case LUA_TSTRING: + new_val = lua_tostring(&s, 2); + break; + default: + if (lua_istable(&s, 2)) { + new_val = popRichType(&s); + if (std::holds_alternative<std::monostate>(new_val)) { + return false; + } + } else { return false; } - } else { - return false; - } + } } return set(new_val); |
