}
else
{
- throw LuaError(NULL, "Expecting itemstack, itemstring, table or nil");
+ throw LuaError(L, "Expecting itemstack, itemstring, table or nil");
}
}
while (lua_next(L, index)) {
s32 key = luaL_checkinteger(L, -2);
if (key < 1) {
- throw LuaError(NULL, "Invalid inventory list index");
+ throw LuaError(L, "Invalid inventory list index");
}
if (items.size() < (u32) key) {
items.resize(key);
{
const char *s = lua_tostring(L, -1);
std::string str(s ? s : "");
- throw LuaError(NULL, str);
+ throw LuaError(L, str);
}
// Push the list of callbacks (a lua table).
if(lua_pcall(L, 7, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_move should return a number");
+ throw LuaError(L, "allow_move should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
if(lua_pcall(L, 5, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_put should return a number");
+ throw LuaError(L, "allow_put should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
if(lua_pcall(L, 5, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_take should return a number");
+ throw LuaError(L, "allow_take should return a number");
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
scriptError();
lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_metadata_inventory_move should"
+ throw LuaError(L, "allow_metadata_inventory_move should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer
scriptError();
lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_metadata_inventory_put should"
+ throw LuaError(L, "allow_metadata_inventory_put should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer
scriptError();
lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1))
- throw LuaError(NULL, "allow_metadata_inventory_take should"
+ throw LuaError(L, "allow_metadata_inventory_take should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer
getAuthHandler();
lua_getfield(L, -1, "get_auth");
if(lua_type(L, -1) != LUA_TFUNCTION)
- throw LuaError(NULL, "Authentication handler missing get_auth");
+ throw LuaError(L, "Authentication handler missing get_auth");
lua_pushstring(L, playername.c_str());
if(lua_pcall(L, 1, 1, errorhandler))
scriptError();
std::string password;
bool found = getstringfield(L, -1, "password", password);
if(!found)
- throw LuaError(NULL, "Authentication handler didn't return password");
+ throw LuaError(L, "Authentication handler didn't return password");
if(dst_password)
*dst_password = password;
lua_getfield(L, -1, "privileges");
if(!lua_istable(L, -1))
- throw LuaError(NULL, "Authentication handler didn't return privilege table");
+ throw LuaError(L, "Authentication handler didn't return privilege table");
if(dst_privs)
readPrivileges(-1, *dst_privs);
lua_pop(L, 1);
}
lua_remove(L, -2); // Remove minetest
if(lua_type(L, -1) != LUA_TTABLE)
- throw LuaError(NULL, "Authentication handler table not valid");
+ throw LuaError(L, "Authentication handler table not valid");
}
void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result)
lua_getfield(L, -1, "create_auth");
lua_remove(L, -2); // Remove auth handler
if(lua_type(L, -1) != LUA_TFUNCTION)
- throw LuaError(NULL, "Authentication handler missing create_auth");
+ throw LuaError(L, "Authentication handler missing create_auth");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
if(lua_pcall(L, 2, 0, errorhandler))
lua_getfield(L, -1, "set_password");
lua_remove(L, -2); // Remove auth handler
if(lua_type(L, -1) != LUA_TFUNCTION)
- throw LuaError(NULL, "Authentication handler missing set_password");
+ throw LuaError(L, "Authentication handler missing set_password");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
if(lua_pcall(L, 2, 1, errorhandler))
if(type == "shaped"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(NULL, "Crafting definition is missing an output");
+ throw LuaError(L, "Crafting definition is missing an output");
int width = 0;
std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
- throw LuaError(NULL, "Crafting definition is missing a recipe"
+ throw LuaError(L, "Crafting definition is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShaped(L, -1, width, recipe))
- throw LuaError(NULL, "Invalid crafting recipe"
+ throw LuaError(L, "Invalid crafting recipe"
" (output=\"" + output + "\")");
CraftReplacements replacements;
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(NULL, "Invalid replacements"
+ throw LuaError(L, "Invalid replacements"
" (output=\"" + output + "\")");
}
else if(type == "shapeless"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(NULL, "Crafting definition (shapeless)"
+ throw LuaError(L, "Crafting definition (shapeless)"
" is missing an output");
std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
- throw LuaError(NULL, "Crafting definition (shapeless)"
+ throw LuaError(L, "Crafting definition (shapeless)"
" is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShapeless(L, -1, recipe))
- throw LuaError(NULL, "Invalid crafting recipe"
+ throw LuaError(L, "Invalid crafting recipe"
" (output=\"" + output + "\")");
CraftReplacements replacements;
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(NULL, "Invalid replacements"
+ throw LuaError(L, "Invalid replacements"
" (output=\"" + output + "\")");
}
else if(type == "cooking"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(NULL, "Crafting definition (cooking)"
+ throw LuaError(L, "Crafting definition (cooking)"
" is missing an output");
std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
- throw LuaError(NULL, "Crafting definition (cooking)"
+ throw LuaError(L, "Crafting definition (cooking)"
" is missing a recipe"
" (output=\"" + output + "\")");
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(NULL, "Invalid replacements"
+ throw LuaError(L, "Invalid replacements"
" (cooking output=\"" + output + "\")");
}
else if(type == "fuel"){
std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
- throw LuaError(NULL, "Crafting definition (fuel)"
+ throw LuaError(L, "Crafting definition (fuel)"
" is missing a recipe");
float burntime = getfloatfield_default(L, table, "burntime", 1.0);
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(NULL, "Invalid replacements"
+ throw LuaError(L, "Invalid replacements"
" (fuel recipe=\"" + recipe + "\")");
}
}
else
{
- throw LuaError(NULL, "Unknown crafting definition type: \"" + type + "\"");
+ throw LuaError(L, "Unknown crafting definition type: \"" + type + "\"");
}
lua_pop(L, 1);