diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-08-14 19:12:14 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-08-14 19:12:14 +0200 |
commit | 9019e18b94940c1e8a2f5f6185692ddf672b61fe (patch) | |
tree | a39c909a2e779dd7687a88e5e2f4311cbc9b0bb0 /src/script/cpp_api | |
parent | 107dec6c0f1be1de9c1049ba4004e5c08d2e34e3 (diff) | |
download | dragonfireclient-9019e18b94940c1e8a2f5f6185692ddf672b61fe.tar.xz |
Some Updates
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_cheats.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/script/cpp_api/s_cheats.cpp b/src/script/cpp_api/s_cheats.cpp index 82a314265..73183c64e 100644 --- a/src/script/cpp_api/s_cheats.cpp +++ b/src/script/cpp_api/s_cheats.cpp @@ -39,7 +39,11 @@ ScriptApiCheatsCheat::ScriptApiCheatsCheat(const std::string &name, const int &f bool ScriptApiCheatsCheat::is_enabled() { - return ! m_function_ref && g_settings->getBool(m_setting); + try { + return ! m_function_ref && g_settings->getBool(m_setting); + } catch (SettingNotFoundException) { + return false; + } } void ScriptApiCheatsCheat::toggle(lua_State *L, int error_handler) @@ -47,8 +51,8 @@ void ScriptApiCheatsCheat::toggle(lua_State *L, int error_handler) if (m_function_ref) { lua_rawgeti(L, LUA_REGISTRYINDEX, m_function_ref); lua_pcall(L, 0, 0, error_handler); - } else - g_settings->setBool(m_setting, !g_settings->getBool(m_setting)); + } else + g_settings->setBool(m_setting, ! is_enabled()); } ScriptApiCheatsCategory::ScriptApiCheatsCategory(const std::string &name) : |