summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua_api.txt4
-rw-r--r--src/script/lua_api/l_settings.cpp6
2 files changed, 8 insertions, 2 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index aba01fa1d..7d568b6e1 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -4131,7 +4131,9 @@ It can be created via `Settings(filename)`.
#### Methods
* `get(key)`: returns a value
-* `get_bool(key)`: returns a boolean
+* `get_bool(key, [default])`: returns a boolean
+ * `default` is the value returned if `key` is not found.
+ * Returns `nil` if `key` is not found and `default` not specified.
* `get_np_group(key)`: returns a NoiseParams table
* `set(key, value)`
* Setting names can't contain whitespace or any of `="{}#`.
diff --git a/src/script/lua_api/l_settings.cpp b/src/script/lua_api/l_settings.cpp
index 141ac61d1..1d56aed5f 100644
--- a/src/script/lua_api/l_settings.cpp
+++ b/src/script/lua_api/l_settings.cpp
@@ -100,7 +100,11 @@ int LuaSettings::l_get_bool(lua_State* L)
bool value = o->m_settings->getBool(key);
lua_pushboolean(L, value);
} else {
- lua_pushnil(L);
+ // Push default value
+ if (lua_isboolean(L, 3))
+ lua_pushboolean(L, lua_toboolean(L, 3));
+ else
+ lua_pushnil(L);
}
return 1;