| 265 | } |
| 266 | |
| 267 | int script_vars_dump(lua_State* L, CScriptVarsTable* svt, bool unpack) // дамп имен и значений переменных в таблицу |
| 268 | { |
| 269 | if (svt) |
| 270 | { |
| 271 | lua_createtable(L, 0, svt->size()); |
| 272 | int tidx = lua_gettop(L); |
| 273 | if (tidx > 100) |
| 274 | { |
| 275 | Msg("script_vars_dump: to many nested tables in dump"); |
| 276 | return 1; |
| 277 | } |
| 278 | |
| 279 | auto it = svt->map().begin(); |
| 280 | for (; it != svt->map().end(); it++) |
| 281 | { |
| 282 | LPCSTR key = *it->first; |
| 283 | SCRIPT_VAR& sv = it->second; |
| 284 | if (sv.is_key_boolean()) |
| 285 | lua_pushboolean(L, 0 == strcmp(key, "true")); |
| 286 | else if (sv.is_key_numeric()) |
| 287 | lua_pushinteger(L, atoi(key)); |
| 288 | else |
| 289 | lua_pushstring(L, key); |
| 290 | |
| 291 | svt->get(L, key, unpack); |
| 292 | lua_settable(L, tidx); |
| 293 | } |
| 294 | } |
| 295 | else |
| 296 | lua_pushnil(L); |
| 297 | |
| 298 | return 1; |
| 299 | } |
| 300 | int script_vars_dump(lua_State* L) // дамп имен и значений переменных в таблицу |
| 301 | { |
| 302 | CScriptVarsTable* svt = lua_tosvt(L, 1); |
no test coverage detected