aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_util.cpp')
-rw-r--r--src/script/lua_api/l_util.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index b25697611..a58c3a196 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -135,7 +135,7 @@ int ModApiUtil::l_write_json(lua_State *L)
bool styled = false;
if (!lua_isnone(L, 2)) {
- styled = lua_toboolean(L, 2);
+ styled = readParam<bool>(L, 2);
lua_pop(L, 1);
}
@@ -231,7 +231,7 @@ int ModApiUtil::l_is_yes(lua_State *L)
lua_getglobal(L, "tostring"); // function to be called
lua_pushvalue(L, 1); // 1st argument
lua_call(L, 1, 1); // execute function
- std::string str(lua_tostring(L, -1)); // get result
+ std::string str = readParam<std::string>(L, -1); // get result
lua_pop(L, 1);
bool yes = is_yes(str);
@@ -342,7 +342,7 @@ int ModApiUtil::l_get_dir_list(lua_State *L)
NO_MAP_LOCK_REQUIRED;
const char *path = luaL_checkstring(L, 1);
bool list_all = !lua_isboolean(L, 2); // if its not a boolean list all
- bool list_dirs = lua_toboolean(L, 2); // true: list dirs, false: list files
+ bool list_dirs = readParam<bool>(L, 2); // true: list dirs, false: list files
CHECK_SECURE_PATH(L, path, false);
@@ -410,7 +410,7 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
}
// Check secure.trusted_mods
- const char *mod_name = lua_tostring(L, -1);
+ std::string mod_name = readParam<std::string>(L, -1);
std::string trusted_mods = g_settings->get("secure.trusted_mods");
trusted_mods.erase(std::remove_if(trusted_mods.begin(),
trusted_mods.end(), static_cast<int(*)(int)>(&std::isspace)),
@@ -451,7 +451,7 @@ int ModApiUtil::l_sha1(lua_State *L)
NO_MAP_LOCK_REQUIRED;
size_t size;
const char *data = luaL_checklstring(L, 1, &size);
- bool hex = !lua_isboolean(L, 2) || !lua_toboolean(L, 2);
+ bool hex = !lua_isboolean(L, 2) || !readParam<bool>(L, 2);
// Compute actual checksum of data
std::string data_sha1;