if(lua_pcall(L, 7, 1, errorhandler))
scriptError();
if(!lua_isnumber(L, -1))
- throw LuaError("allow_move should return a number");
+ throw LuaError("allow_move should return a number. name=" + name);
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("allow_put should return a number");
+ throw LuaError("allow_put should return a number. name=" + name);
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("allow_take should return a number");
+ throw LuaError("allow_take should return a number. name=" + name);
int ret = luaL_checkinteger(L, -1);
lua_pop(L, 2); // Pop integer and error handler
return ret;
pushFloatPos(L, pos);
if(lua_pcall(L, 3, 1, errorhandler))
scriptError();
- if(!lua_isnil(L, -1))
- item = read_item(L,-1, getServer());
+ if(!lua_isnil(L, -1)) {
+ try {
+ item = read_item(L,-1, getServer());
+ } catch (LuaError &e) {
+ throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ }
+ }
lua_pop(L, 2); // Pop item and error handler
return true;
}
pushPointedThing(pointed);
if(lua_pcall(L, 3, 1, errorhandler))
scriptError();
- if(!lua_isnil(L, -1))
- item = read_item(L,-1, getServer());
+ if(!lua_isnil(L, -1)) {
+ try {
+ item = read_item(L,-1, getServer());
+ } catch (LuaError &e) {
+ throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ }
+ }
lua_pop(L, 2); // Pop item and error handler
return true;
}
pushPointedThing(pointed);
if(lua_pcall(L, 3, 1, errorhandler))
scriptError();
- if(!lua_isnil(L, -1))
- item = read_item(L,-1, getServer());
+ if(!lua_isnil(L, -1)) {
+ try {
+ item = read_item(L,-1, getServer());
+ } catch (LuaError &e) {
+ throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ }
+ }
lua_pop(L, 2); // Pop item and error handler
return true;
}
InvRef::create(L, craft_inv);
if(lua_pcall(L, 4, 1, errorhandler))
scriptError();
- if(!lua_isnil(L, -1))
- item = read_item(L,-1, getServer());
+ if(!lua_isnil(L, -1)) {
+ try {
+ item = read_item(L,-1, getServer());
+ } catch (LuaError &e) {
+ throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ }
+ }
lua_pop(L, 2); // Pop item and error handler
return true;
}
InvRef::create(L, craft_inv);
if(lua_pcall(L, 4, 1, errorhandler))
scriptError();
- if(!lua_isnil(L, -1))
- item = read_item(L,-1, getServer());
+ if(!lua_isnil(L, -1)) {
+ try {
+ item = read_item(L,-1, getServer());
+ } catch (LuaError &e) {
+ throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ }
+ }
lua_pop(L, 2); // Pop item and error handler
return true;
}