diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-04-21 21:51:08 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-04-21 22:12:06 +0200 |
commit | 2efd080bc10708656ca0b48694b7f37d7a02771d (patch) | |
tree | 236665989ff9a4a1f7b67f3aac35b2c5ffe06212 /crawl-ref/source/l_item.cc | |
parent | 68d7b4c9d7cf9f10feb01855374068160f0103aa (diff) | |
download | crawl-ref-2efd080bc10708656ca0b48694b7f37d7a02771d.tar.gz crawl-ref-2efd080bc10708656ca0b48694b7f37d7a02771d.zip |
Revert get_items_at -> get_item_at, fix it not working out of LOS, fix crashes.
It doesn't actually work for any items but the top yet, but at least the
interface won't change.
This reverts commit 198c943b116acfd9a1997c48073f29e520e7c0c4.
Diffstat (limited to 'crawl-ref/source/l_item.cc')
-rw-r--r-- | crawl-ref/source/l_item.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc index dff7b3dd4b..2d97f2dc2d 100644 --- a/crawl-ref/source/l_item.cc +++ b/crawl-ref/source/l_item.cc @@ -985,16 +985,32 @@ static int l_item_inslot(lua_State *ls) return (1); } -static int l_item_get_item_at(lua_State *ls) +static int l_item_get_items_at(lua_State *ls) { - COORDSHOW(s, 1, 2) + coord_def s; + s.x = luaL_checkint(ls, 1); + s.y = luaL_checkint(ls, 2); coord_def p = player2grid(s); + if (!map_bounds(p)) + return 0; - const int item = you.visible_igrd(p); - if (you.see_cell(p) && item != NON_ITEM) - clua_push_item(ls, &mitm[item]); - else - lua_pushnil(ls); + item_def* top = env.map_knowledge(p).item(); + if (!top || !top->defined()) + return 0; + + lua_newtable(ls); + + // FIXME: the whole known stash should be pushed + clua_push_item(ls, top); + lua_rawseti(ls, -2, 1); +#if 0 + int index = 0; + for (; link != NON_ITEM; link = mitm[link].link) + { + clua_push_item(ls, &mitm[link]); + lua_rawseti(ls, -2, ++index); + } +#endif return (1); } @@ -1074,7 +1090,7 @@ static const struct luaL_reg item_lib[] = { "equipped_at", l_item_equipped_at }, { "fired_item", l_item_fired_item }, { "inslot", l_item_inslot }, - { "get_item_at", l_item_get_item_at }, + { "get_items_at", l_item_get_items_at }, { NULL, NULL }, }; |