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

Function Sys_GetConfigString

engine/script/src/script_sys.cpp:481–503  ·  view source on GitHub ↗

get string config value with optional default value * Get string config value from the game.project configuration file with optional default value * * @name sys.get_config_string * @param key [type:string] key to get value for. The syntax is SECTION.KEY * @param [default_value] [type:string] (optional) default value to return if the value does not exist * @return valu

Source from the content-addressed store, hash-verified

479 * ```
480 */
481 static int Sys_GetConfigString(lua_State* L)
482 {
483 DM_LUA_STACK_CHECK(L, 1);
484
485 const char* key = luaL_checkstring(L, 1);
486 const char* default_value = 0;
487 if (lua_isstring(L, 2))
488 {
489 default_value = lua_tostring(L, 2);
490 }
491
492 dmConfigFile::HConfig config_file = GetConfigFile(L);
493 if (config_file)
494 {
495 const char* value = dmConfigFile::GetString(config_file, key, default_value);
496 lua_pushstring(L, value);
497 }
498 else
499 {
500 lua_pushnil(L);
501 }
502 return 1;
503 }
504
505 /*# get integer config value with optional default value
506 * Get integer config value from the game.project configuration file with optional default value

Callers

nothing calls this directly

Calls 5

lua_isstringFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushnilFunction · 0.85
GetConfigFileFunction · 0.70
GetStringFunction · 0.50

Tested by

no test coverage detected