diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-21 08:10:22 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-21 08:10:22 +0000 |
commit | 7d74044829242da97e6db5c87b336f4c1a17883e (patch) | |
tree | 70df8c1ce51f557b1da728a3c4ac90e5dc374cfb /crawl-ref/source/clua.cc | |
parent | b14c7ddf0477e480f57150ad383482e962c257b0 (diff) | |
download | crawl-ref-7d74044829242da97e6db5c87b336f4c1a17883e.tar.gz crawl-ref-7d74044829242da97e6db5c87b336f4c1a17883e.zip |
Really fix pickup.lua not to search for a butchering tool if you're
wielding a cursed sharp-edged weapon. (My previous "fix" was preventing
auto-picking up a butchering tool, at all!)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6031 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r-- | crawl-ref/source/clua.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 4eba44779f..90c1cda06f 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1141,6 +1141,20 @@ static int l_item_pickup(lua_State *ls) static int l_item_equipped(lua_State *ls) { + LUA_ITEM(item, 1); + if (!item || !in_inventory(*item)) + return (0); + + int eq = get_equip_slot(item); + if (eq < 0 || eq >= NUM_EQUIP) + return (0); + + return (1); +} + +// Returns item equipped in a slot defined in an argument. +static int l_item_equipped_at(lua_State *ls) +{ int eq = -1; if (lua_isnumber(ls, 1)) eq = luaL_checkint(ls, 1); @@ -1481,7 +1495,8 @@ static const struct luaL_reg item_lib[] = { "remove", l_item_remove }, { "drop", l_item_drop }, { "pickup", l_item_pickup }, - { "equipped_at", l_item_equipped }, + { "equipped_at", l_item_equipped_at }, + { "equipped", l_item_equipped }, { "equip_type", l_item_equip_type }, { "weap_skill", l_item_weap_skill }, { "dropped", l_item_dropped }, |