summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2018-06-30 17:11:38 +0200
committerGitHub <noreply@github.com>2018-06-30 17:11:38 +0200
commiteef62c82a2e58700fc1216b0b8c03e421bc77995 (patch)
tree4c49e659069036cb53d69535dc33d33f29d963f4 /src/script/lua_api/l_mainmenu.cpp
parent227c71eb76e019873b30e2d3893b68307d51d58f (diff)
downloadminetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.tar.gz
minetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.tar.bz2
minetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.zip
Modernize lua read (part 2 & 3): C++ templating assurance (#7410)
* Modernize lua read (part 2 & 3): C++ templating assurance Implement the boolean reader Implement the string reader Also remove unused & unimplemented script_error_handler Add a reader with default value
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 238e3e32f..03b8fe223 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -83,7 +83,7 @@ int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
}
valid = true;
- return lua_toboolean(L, -1);
+ return readParam<bool>(L, -1);
}
/******************************************************************************/
@@ -158,7 +158,7 @@ int ModApiMainMenu::l_set_background(lua_State *L)
unsigned int minsize = 16;
if (!lua_isnone(L, 3)) {
- tile_image = lua_toboolean(L, 3);
+ tile_image = readParam<bool>(L, 3);
}
if (!lua_isnone(L, 4)) {
@@ -195,7 +195,7 @@ int ModApiMainMenu::l_set_clouds(lua_State *L)
GUIEngine* engine = getGuiEngine(L);
sanity_check(engine != NULL);
- bool value = lua_toboolean(L,1);
+ bool value = readParam<bool>(L,1);
engine->m_clouds_enabled = value;
@@ -627,7 +627,8 @@ int ModApiMainMenu::l_set_topleft_text(lua_State *L)
int ModApiMainMenu::l_get_mapgen_names(lua_State *L)
{
std::vector<const char *> names;
- Mapgen::getMapgenNames(&names, lua_toboolean(L, 1));
+ bool include_hidden = lua_isboolean(L, 1) && readParam<bool>(L, 1);
+ Mapgen::getMapgenNames(&names, include_hidden);
lua_newtable(L);
for (size_t i = 0; i != names.size(); i++) {
@@ -722,7 +723,7 @@ int ModApiMainMenu::l_copy_dir(lua_State *L)
if ((!lua_isnone(L,3)) &&
(!lua_isnil(L,3))) {
- keep_source = lua_toboolean(L,3);
+ keep_source = readParam<bool>(L,3);
}
std::string absolute_destination = fs::RemoveRelativePathComponents(destination);
@@ -871,7 +872,7 @@ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L)
const char *formname= luaL_checkstring(L, 1);
const char *title = luaL_checkstring(L, 2);
- bool is_file_select = lua_toboolean(L, 3);
+ bool is_file_select = readParam<bool>(L, 3);
GUIFileSelectMenu* fileOpenMenu =
new GUIFileSelectMenu(RenderingEngine::get_gui_env(),