Modernize lua read (part 2 & 3): C++ templating assurance (#7410)
[oweals/minetest.git] / src / script / cpp_api / s_server.cpp
index b0459fbfa0b77879785eb5922c2d5aa6d877fc2e..3b461a2a3b66a9214c55aa66a52ca752e5c0c441 100644 (file)
@@ -88,7 +88,7 @@ void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result)
        while (lua_next(L, index) != 0) {
                // key at index -2 and value at index -1
                std::string key = luaL_checkstring(L, -2);
-               bool value = lua_toboolean(L, -1);
+               bool value = readParam<bool>(L, -1);
                if (value)
                        result.insert(key);
                // removes value, keeps key for next iteration
@@ -143,8 +143,7 @@ bool ScriptApiServer::on_chat_message(const std::string &name,
        lua_pushstring(L, name.c_str());
        lua_pushstring(L, message.c_str());
        runCallbacks(2, RUN_CALLBACKS_MODE_OR_SC);
-       bool ate = lua_toboolean(L, -1);
-       return ate;
+       return readParam<bool>(L, -1);
 }
 
 void ScriptApiServer::on_mods_loaded()