From 9019e18b94940c1e8a2f5f6185692ddf672b61fe Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 14 Aug 2020 19:12:14 +0200 Subject: Some Updates --- src/script/cpp_api/s_cheats.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/script/cpp_api/s_cheats.cpp') 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) : -- cgit v1.2.3