MCPcopy Create free account
hub / github.com/defold/defold / Sys_GetConfigInt

Function Sys_GetConfigInt

engine/script/src/script_sys.cpp:527–549  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

luaL_checkintegerFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushnilFunction · 0.85
GetConfigFileFunction · 0.70
GetIntFunction · 0.50

Tested by

no test coverage detected