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

Function Sys_GetConfigNumber

engine/script/src/script_sys.cpp:566–588  ·  view source on GitHub ↗

get number config value with optional default value * Get number config value from the game.project configuration file with optional default value * * @name sys.get_config_number * @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 valu

Source from the content-addressed store, hash-verified

564 * ```
565 */
566 static int Sys_GetConfigNumber(lua_State* L)
567 {
568 DM_LUA_STACK_CHECK(L, 1);
569
570 const char* key = luaL_checkstring(L, 1);
571 float default_value = 0;
572 if (!lua_isnone(L, 2))
573 {
574 default_value = luaL_checknumber(L, 2);
575 }
576
577 dmConfigFile::HConfig config_file = GetConfigFile(L);
578 if (config_file)
579 {
580 float value = dmConfigFile::GetFloat(config_file, key, default_value);
581 lua_pushnumber(L, value);
582 }
583 else
584 {
585 lua_pushnil(L);
586 }
587 return 1;
588 }
589
590 /*# get boolean config value with optional default value
591 * Get boolean config value from the game.project configuration file with optional default value

Callers

nothing calls this directly

Calls 5

luaL_checknumberFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushnilFunction · 0.85
GetConfigFileFunction · 0.70
GetFloatFunction · 0.50

Tested by

no test coverage detected