summaryrefslogtreecommitdiff
path: root/lib/core/auto.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/auto.lua')
-rw-r--r--lib/core/auto.lua54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/core/auto.lua b/lib/core/auto.lua
index fa2457ff..ba613664 100644
--- a/lib/core/auto.lua
+++ b/lib/core/auto.lua
@@ -196,6 +196,38 @@ function gen_rule_fct(r)
f = gen_rule_fct(r[1])
end
return function(object) return not %f(object) end
+ elseif r.label == "inventory" then
+ local f
+ if not r[1] then
+ f = function(object) return end
+ else
+ f = gen_rule_fct(r[1])
+ end
+ return function(object)
+ local i = 0
+ while i < INVEN_WIELD do
+ if %f(player.inventory(i)) then
+ return TRUE
+ end
+ i = i + 1
+ end
+ end
+ elseif r.label == "equipment" then
+ local f
+ if not r[1] then
+ f = function(object) return end
+ else
+ f = gen_rule_fct(r[1])
+ end
+ return function(object)
+ local i = INVEN_WIELD
+ while i < INVEN_TOTAL do
+ if %f(player.inventory(i)) then
+ return TRUE
+ end
+ i = i + 1
+ end
+ end
elseif r.label == "name" then
return function(object) if strlower(object_desc(object, -1, 0)) == strlower(%r[1]) then return TRUE end end
elseif r.label == "contain" then
@@ -737,6 +769,28 @@ auto_aux.types_desc =
return xml:collect("<ability>"..n.."</ability>")
end,
},
+ ["inventory"] =
+ {
+ {
+ "Check is true if something in player's inventory matches",
+ "the contained rule",
+ },
+ xml:collect([[<inventory><foo1>...</foo1></inventory>]]),
+ function ()
+ return xml:collect("<inventory></inventory>")
+ end,
+ },
+ ["equipment"] =
+ {
+ {
+ "Check is true if something in player's equipment matches",
+ "the contained rule",
+ },
+ xml:collect([[<equipment><foo1>...</foo1></equipment>]]),
+ function ()
+ return xml:collect("<equipment></equipment>")
+ end,
+ },
}
function auto_aux:display_desc(sel)