diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_inventory.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index 67b78bcaf..d783cf60f 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -117,24 +117,38 @@ int InvRef::l_set_size(lua_State *L) NO_MAP_LOCK_REQUIRED; InvRef *ref = checkobject(L, 1); const char *listname = luaL_checkstring(L, 2); + int newsize = luaL_checknumber(L, 3); + if (newsize < 0) { + lua_pushboolean(L, false); + return 1; + } + Inventory *inv = getinv(L, ref); if(inv == NULL){ - return 0; + lua_pushboolean(L, false); + return 1; } if(newsize == 0){ inv->deleteList(listname); reportInventoryChange(L, ref); - return 0; + lua_pushboolean(L, true); + return 1; } InventoryList *list = inv->getList(listname); if(list){ list->setSize(newsize); } else { list = inv->addList(listname, newsize); + if (!list) + { + lua_pushboolean(L, false); + return 1; + } } reportInventoryChange(L, ref); - return 0; + lua_pushboolean(L, true); + return 1; } // set_width(self, listname, size) |