diff options
Diffstat (limited to 'src/script/cpp_api/s_cheats.cpp')
-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) : |