get integer config value with optional default value * Get integer config value from the game.project configuration file with optional default value * * @name sys.get_config_int * @param key [type:string] key to get value for. The syntax is SECTION.KEY * @param [default_value] [type:number] (optional) default value to return if the value does not exist * @return value
| 525 | * ``` |
| 526 | */ |
| 527 | static int Sys_GetConfigInt(lua_State* L) |
| 528 | { |
| 529 | DM_LUA_STACK_CHECK(L, 1); |
| 530 | |
| 531 | const char* key = luaL_checkstring(L, 1); |
| 532 | int default_value = 0; |
| 533 | if (!lua_isnone(L, 2)) |
| 534 | { |
| 535 | default_value = luaL_checkinteger(L, 2); |
| 536 | } |
| 537 | |
| 538 | dmConfigFile::HConfig config_file = GetConfigFile(L); |
| 539 | if (config_file) |
| 540 | { |
| 541 | int value = dmConfigFile::GetInt(config_file, key, default_value); |
| 542 | lua_pushinteger(L, value); |
| 543 | } |
| 544 | else |
| 545 | { |
| 546 | lua_pushnil(L); |
| 547 | } |
| 548 | return 1; |
| 549 | } |
| 550 | |
| 551 | /*# get number config value with optional default value |
| 552 | * Get number config value from the game.project configuration file with optional default value |
nothing calls this directly
no test coverage detected