diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-02-11 19:48:57 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-02-11 19:48:57 +0100 |
commit | afe3490781c1d35e452a52a53988526b72cea61e (patch) | |
tree | d5aaf55b693a5e5c6cf6a4f3064356b899dc5321 /src/scripting/lua.cpp | |
parent | ea6f5cc77d90a8791fb8e66d4c4fe98135fe2e78 (diff) | |
download | manaserv-afe3490781c1d35e452a52a53988526b72cea61e.tar.gz manaserv-afe3490781c1d35e452a52a53988526b72cea61e.tar.bz2 manaserv-afe3490781c1d35e452a52a53988526b72cea61e.tar.xz manaserv-afe3490781c1d35e452a52a53988526b72cea61e.zip |
Fix basic money handling using the ATTR_GP attribute.
Reviewed-by: Freeyorp.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 294dbd48..8be31f46 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -367,11 +367,14 @@ static int chr_inv_change(lua_State *s) raiseScriptError(s, "chr_inv_change called with incorrect parameters."); return 0; } + int id = lua_tointeger(s, i * 2 + 2); int nb = lua_tointeger(s, i * 2 + 3); - if (id == 0) - LOG_WARN("chr_inv_change: id 0! Currency is now handled through attributes!"); + { + LOG_WARN("mana.chr_inv_change() called with id 0! " + "Currency is now handled through attributes!"); + } else if (nb < 0) { nb = inv.remove(id, -nb); @@ -419,10 +422,21 @@ static int chr_inv_count(lua_State *s) int nb_items = lua_gettop(s) - 1; lua_checkstack(s, nb_items); Inventory inv(q); + + int id, nb = 0; for (int i = 2; i <= nb_items + 1; ++i) { - int nb = inv.count(luaL_checkint(s, i)); - lua_pushinteger(s, nb); + id = luaL_checkint(s, i); + if (id == 0) + { + LOG_WARN("mana.chr_inv_count() called with id 0! " + "Currency is now handled through attributes!"); + } + else + { + nb = inv.count(id); + lua_pushinteger(s, nb); + } } return nb_items; } |