diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-09-21 20:38:23 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-09-21 20:38:52 +0200 |
commit | 0f525c92dece8b302356c63864c6209309293184 (patch) | |
tree | 1b477cc9a51c84da0b0005c025c9a756cb93d481 /src | |
parent | c34929b7e8afc158f190c9a224384457df5063cc (diff) | |
download | manaserv-0f525c92dece8b302356c63864c6209309293184.tar.gz manaserv-0f525c92dece8b302356c63864c6209309293184.tar.bz2 manaserv-0f525c92dece8b302356c63864c6209309293184.tar.xz manaserv-0f525c92dece8b302356c63864c6209309293184.zip |
Fixed implementation of entity_inv_count
Was still checking for booleans and using the wrong stack indexes.
Diffstat (limited to 'src')
-rw-r--r-- | src/scripting/lua.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 0c235e5d..af666bb8 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -912,23 +912,16 @@ static int trade(lua_State *s) static int entity_inv_count(lua_State *s) { Entity *q = checkCharacter(s, 1); - if (!lua_isboolean(s, 2) || !lua_isboolean(s, 3)) - { - luaL_error(s, "inv_count called with incorrect parameters."); - return 0; - } - int nb_items = lua_gettop(s) - 1; + const int itemCount = lua_gettop(s) - 1; Inventory inv(q); - int nb = 0; - for (int i = 4; i < nb_items + 4; ++i) + for (int i = 2; i < itemCount + 2; ++i) { - ItemClass *it = checkItemClass(s, i); - nb = inv.count(it->getDatabaseID()); - lua_pushinteger(s, nb); + const ItemClass *it = checkItemClass(s, i); + lua_pushinteger(s, inv.count(it->getDatabaseID())); } - return nb_items; + return itemCount; } /** LUA entity:inv_change (inventory) |