From b06c289636354686e9bd6b60024f4526af3bb118 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Sun, 8 Nov 2009 23:43:22 -0800 Subject: 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. --- crawl-ref/source/dat/clua/lm_flags.lua | 4 +++- crawl-ref/source/dat/clua/lm_trig.lua | 28 ++++++++++++++++++++++------ crawl-ref/source/dat/crypt.des | 2 +- crawl-ref/source/dat/hells.des | 8 ++++---- crawl-ref/source/dat/zot.des | 2 +- 5 files changed, 31 insertions(+), 13 deletions(-) (limited to 'crawl-ref/source/dat') 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 diff --git a/crawl-ref/source/dat/crypt.des b/crawl-ref/source/dat/crypt.des index 68cf62a3bc..fc1b47be6a 100644 --- a/crawl-ref/source/dat/crypt.des +++ b/crawl-ref/source/dat/crypt.des @@ -1010,7 +1010,7 @@ SUBST: $ = *:2 |:1 $:17 MONS: mummy, guardian mummy, mummy priest, greater mummy # MARKER: O = lua:item_pickup_change_flags { \ - branch_flags="!no_tele_control", item="golden rune of Zot" \ + branch_flags="!no_tele_control", item="auto" \ } MAP xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/crawl-ref/source/dat/hells.des b/crawl-ref/source/dat/hells.des index 1ff9800efa..ebe246c828 100644 --- a/crawl-ref/source/dat/hells.des +++ b/crawl-ref/source/dat/hells.des @@ -10,7 +10,7 @@ function dis_setup(e) e.tags(no_rotate) e.lflags("no_tele_control") e.lua_marker('O', item_pickup_change_flags { - level_flags="!no_tele_control", item="iron rune of Zot" } ) + level_flags="!no_tele_control", item="auto" } ) -- turn granite statues into iron statues -- you still have to colour the statues, if desired dgn.set_feature_desc_short("granite statue", "iron statue") @@ -23,7 +23,7 @@ function geh_setup(e) e.tags(no_rotate) e.lflags("no_tele_control") e.lua_marker('O', item_pickup_change_flags { - level_flags="!no_tele_control", item="obsidian rune of Zot" } ) + level_flags="!no_tele_control", item="auto" } ) e.lrockcol("brown") e.lfloorcol("darkgrey") -- e.lrocktile("???") @@ -42,7 +42,7 @@ function coc_setup(e) e.tags(no_rotate) e.lflags("no_tele_control") e.lua_marker('O', item_pickup_change_flags { - level_flags="!no_tele_control", item="icy rune of Zot" } ) + level_flags="!no_tele_control", item="auto" } ) e.lrockcol("lightgrey") e.lfloorcol("white") -- e.lrocktile("???") @@ -62,7 +62,7 @@ function tar_setup(e) e.tags(no_rotate) e.lflags("no_tele_control") e.lua_marker('O', item_pickup_change_flags { - level_flags="!no_tele_control", item="bone rune of Zot" } ) + level_flags="!no_tele_control", item="auto" } ) end }} diff --git a/crawl-ref/source/dat/zot.des b/crawl-ref/source/dat/zot.des index a416dd2543..bdc8ee1d46 100644 --- a/crawl-ref/source/dat/zot.des +++ b/crawl-ref/source/dat/zot.des @@ -333,7 +333,7 @@ ORIENT: north TAGS: no_dump LFLAGS: no_tele_control MARKER: Z = lua:item_pickup_change_flags { \ - level_flags="!no_tele_control", item="Orb of Zot" \ + level_flags="!no_tele_control", item="auto" \ } LFLOORCOL: magenta LROCKCOL: lightmagenta -- cgit v1.2.3-54-g00ecf