summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-08 23:43:22 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-08 23:44:52 -0800
commitb06c289636354686e9bd6b60024f4526af3bb118 (patch)
tree37f3471268ffa6cf1f3864a1d345119c179290ea /crawl-ref/source/dat/clua
parentdce267d966c2a6466ebc57f84dccda7fa5012a75 (diff)
downloadcrawl-ref-b06c289636354686e9bd6b60024f4526af3bb118.tar.gz
crawl-ref-b06c289636354686e9bd6b60024f4526af3bb118.zip
item_pickup_change_flags: "auto" item name
item_pickup_change_flags (and the underlying DgnTriggerable) can take the item name "auto", in which case it automatically picks the item placed on top of the marker.
Diffstat (limited to 'crawl-ref/source/dat/clua')
-rw-r--r--crawl-ref/source/dat/clua/lm_flags.lua4
-rw-r--r--crawl-ref/source/dat/clua/lm_trig.lua28
2 files changed, 25 insertions, 7 deletions
diff --git a/crawl-ref/source/dat/clua/lm_flags.lua b/crawl-ref/source/dat/clua/lm_flags.lua
index c6b93b7a2b..996cd9dd52 100644
--- a/crawl-ref/source/dat/clua/lm_flags.lua
+++ b/crawl-ref/source/dat/clua/lm_flags.lua
@@ -52,7 +52,9 @@
-- an item on its grid gets picked up. Accepts the parameter
-- "item", which is the plain name of the item its watching
-- (i.e., "Orb of Zot" and "golden rune of Zot" rather than
--- "the Orb of Zot" or "a golden rune of Zot").
+-- "the Orb of Zot" or "a golden rune of Zot"). You can also
+-- just use "auto", in which case whichever item is on top of
+-- the marker will autoamically be chosen.
--
-- ChangeFlags is a Triggerable subclass, and the above three functions
-- are just convenience functions which add a single triggerer. Other
diff --git a/crawl-ref/source/dat/clua/lm_trig.lua b/crawl-ref/source/dat/clua/lm_trig.lua
index 11d47607f8..d08d3fa1bd 100644
--- a/crawl-ref/source/dat/clua/lm_trig.lua
+++ b/crawl-ref/source/dat/clua/lm_trig.lua
@@ -537,14 +537,17 @@ end
--
-- * item_moved: Wait for an item to move from one cell to another.
-- Needs the parameter "target", who's value is the name of the
--- item that is being tracked. The triggerable/marker must be placed
--- on top of the cell containing the item.
+-- item that is being tracked, or which can be "auto", in which
+-- case it will pick the item placed by the vault. The
+-- triggerable/marker must be placed on top of the cell containing
+-- the item.
--
-- * item_pickup: Wait for an item to be picked up. Needs the parameter
--- "target", who's value is the name of the item that is being tracked.
--- The triggerable/marker must be placed on top of the cell containing
--- the item. Automatically takes care of the item moving from one
--- square to another without being picked up.
+-- "target", who's value is the name of the item that is being tracked,
+-- or which can be "auto", in which case it will pick the item placed
+-- by the vault. The triggerable/marker must be placed on top of the
+-- cell containing the item. Automatically takes care of the item
+-- moving from one square to another without being picked up.
--
-- * player_move: Wait for the player to move to a cell. The
-- triggerable/marker must be placed on top of cell in question.
@@ -626,6 +629,19 @@ function DgnTriggerer:activate(triggerable, marker, x, y)
error("DgnTriggerer:activate(): triggerable is not activated")
end
+ if self.type == "item_moved" or self.type == "item_pickup" then
+ if self.target == "auto" then
+ local items = dgn.items_at(marker:pos())
+
+ if #items == 0 then
+ error("No vault item for " .. self.type)
+ elseif #items > 1 then
+ error("Too many vault items for " .. self.type)
+ end
+ self.target = item.name(items[1])
+ end
+ end
+
local et = dgn.dgn_event_type(self.type)
if (dgn.dgn_event_is_position(et)) then