summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/lua/pickup.lua
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/lua/pickup.lua')
-rw-r--r--crawl-ref/source/lua/pickup.lua47
1 files changed, 29 insertions, 18 deletions
diff --git a/crawl-ref/source/lua/pickup.lua b/crawl-ref/source/lua/pickup.lua
index 452ef0b965..26f68efec1 100644
--- a/crawl-ref/source/lua/pickup.lua
+++ b/crawl-ref/source/lua/pickup.lua
@@ -1,16 +1,18 @@
----------------------------------------------------------------------------
+------------------------------------------------------------
-- pickup.lua:
--- Smarter autopickup handling that takes into account the item type
--- in combination with your character's race, religion, knowledge,
--- and eating habits.
+-- Smarter autopickup handling that takes into account the
+-- item type in combination with your character's race,
+-- religion, knowledge, and eating habits.
--
-- To use this, add this line to your init.txt:
-- lua_file = lua/pickup.lua
--
-- Notes:
--- * This script only handles items of classes with autopickup on.
--- * Any result can still be overridden using autopickup_exceptions.
----------------------------------------------------------------------------
+-- * This script only handles items of classes with
+-- autopickup on.
+-- * Any result can still be overridden using
+-- autopickup_exceptions.
+------------------------------------------------------------
function make_hash(ls)
local h = { }
@@ -21,7 +23,8 @@ function make_hash(ls)
end
function you_undead()
- return you.race() == "Mummy" or you.race() == "Ghoul" or you.race() == "Vampire"
+ return you.race() == "Mummy" or you.race() == "Ghoul"
+ or you.race() == "Vampire"
end
-- not identified
@@ -33,12 +36,12 @@ function good_potion(type)
return type == 1
end
-function bad_potion(it)
+function bad_potion(type)
return type == 2
end
-- special cases
-function spec_potion(it)
+function spec_potion(type)
return type == 3
end
@@ -54,7 +57,8 @@ function ch_autopickup(it)
return true
end
- -- no potions for Mummies, also: no bad potions for anyone else
+ -- no potions for Mummies
+ -- also: no bad potions for anyone else
if you.race() == "Mummy" or bad_potion(type) then
return false
end
@@ -68,7 +72,10 @@ function ch_autopickup(it)
if spec_potion(type) then
-- undead cannot use berserk
- if item.subtype(it) == "berserk" then
+ -- or anything involving mutations
+ if item.subtype(it) == "berserk"
+ or item.subtype(it) == "gain ability"
+ or item.subtype(it) == "cure mutation" then
if you_undead() then
return false
else
@@ -77,7 +84,8 @@ function ch_autopickup(it)
end
-- special cases for blood, water, and porridge
- if item.subtype(it) == "blood" or item.subtype(it) == "water"
+ if item.subtype(it) == "blood"
+ or item.subtype(it) == "water"
or item.subtype(it) == "porridge" then
return food.can_eat(it, false)
end
@@ -87,20 +95,23 @@ function ch_autopickup(it)
return true
end
- if item.class(it) == "Carrion" or item.class(it) == "Comestibles" then
+ if item.class(it) == "Carrion"
+ or item.class(it) == "Comestibles" then
return food.can_eat(it, false)
end
- if item.class(it) == "Books" and you.god() == "Trog" then
- return false
+ if item.class(it) == "Books" and you.god() == "Trog"
+ then return false
end
if item.class(it) == "Jewellery" then
- if item.subtype == "hunger" or item.subtype == "inaccuracy" then
+ if item.subtype(it) == "hunger"
+ or item.subtype(it) == "inaccuracy" then
return false
end
if you_undead() and
- (item.subtype(it) == "regeneration" or item.subtype(it) == "rage") then
+ (item.subtype(it) == "regeneration"
+ or item.subtype(it) == "rage") then
return false
end
end