| 149 | } |
| 150 | |
| 151 | std::optional<double> numberField(lua_State* L, int table_idx, const char* key) { |
| 152 | lua_rawgetfield(L, table_idx, key); |
| 153 | std::optional<double> out; |
| 154 | if (lua_isnumber(L, -1)) { |
| 155 | out = lua_tonumber(L, -1); |
| 156 | } |
| 157 | lua_pop(L, 1); |
| 158 | return out; |
| 159 | } |
| 160 | |
| 161 | // Top-of-stack Lua scalar -> JSON (numbers/bools/strings; else null). |
| 162 | nlohmann::json luaScalarToJson(lua_State* L, int idx) { |