From 7b7f0f9f0bfa18cad05902305e8e0a84a0c7ff86 Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Fri, 8 Jan 2010 22:45:34 +1000 Subject: Lua item pluses wrapper. Will only report pluses in instances where pluses are actually known to the player. --- crawl-ref/source/l_item.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crawl-ref/source/l_item.cc') diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc index ecd343be2a..1e0d3bcc57 100644 --- a/crawl-ref/source/l_item.cc +++ b/crawl-ref/source/l_item.cc @@ -733,6 +733,24 @@ static int l_item_do_inc_quantity(lua_State *ls) return (0); } +static int l_item_pluses(lua_State *ls) +{ + LUA_ITEM(item, 1); + + if (!item || !item->is_valid() || !item_ident(*item, ISFLAG_KNOW_PLUSES)) + { + lua_pushboolean(ls, false); + return (0); + } + + lua_pushnumber(ls, item->plus); + // XXX: May cause issues on items that don't use plus2, ie ammunition. + lua_pushnumber(ls, item->plus2); + + return (2); +} + + static const struct luaL_reg item_lib[] = { { "artefact", l_item_artefact }, @@ -766,6 +784,7 @@ static const struct luaL_reg item_lib[] = { "destroy", l_item_do_destroy }, { "dec_quantity", l_item_do_dec_quantity }, { "inc_quantity", l_item_do_inc_quantity }, + { "pluses", l_item_pluses }, { NULL, NULL }, }; -- cgit v1.2.3-54-g00ecf