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

Function Sys_GetConfigBoolean

engine/script/src/script_sys.cpp:605–628  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

603 * ```
604 */
605 static int Sys_GetConfigBoolean(lua_State* L)
606 {
607 DM_LUA_STACK_CHECK(L, 1);
608
609 const char* key = luaL_checkstring(L, 1);
610 bool default_value = false;
611 if (!lua_isnone(L, 2))
612 {
613 default_value = lua_toboolean(L, 2);
614 }
615
616 dmConfigFile::HConfig config_file = GetConfigFile(L);
617 if (config_file)
618 {
619 int32_t int_value = dmConfigFile::GetInt(config_file, key, default_value ? 1 : 0);
620 bool value = int_value != 0;
621 lua_pushboolean(L, value);
622 }
623 else
624 {
625 lua_pushnil(L);
626 }
627 return 1;
628 }
629
630 /*# open url in default application
631 * Open URL in default application, typically a browser

Callers

nothing calls this directly

Calls 5

lua_tobooleanFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_pushnilFunction · 0.85
GetConfigFileFunction · 0.70
GetIntFunction · 0.50

Tested by

no test coverage detected