aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorJordan Irwin <antumdeluge@gmail.com>2017-12-17 07:27:37 -0800
committerrubenwardy <rubenwardy@gmail.com>2017-12-17 15:27:37 +0000
commit18b921015a33c6e597f480bccc7e2974af33c4ea (patch)
treeeb8a13a020e340870d772e72455cfcf3289504de /src/script/lua_api
parent26c7e98e3d87446acbc0c30b3c0ea8eb8bc1f6c5 (diff)
downloadminetest-18b921015a33c6e597f480bccc7e2974af33c4ea.tar.gz
minetest-18b921015a33c6e597f480bccc7e2974af33c4ea.tar.bz2
minetest-18b921015a33c6e597f480bccc7e2974af33c4ea.zip
Allow 'default' parameter in 'settings:get_bool' function
Default value is used when the setting key is not found in the config file. If default value is not set, 'nil' is returned. #6188
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_settings.cpp6
1 files changed, 5 insertions, 1 deletions
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;