Floor trigger and flying monsters
Floor trigger and flying monsters
Is there a way for flying units to activate floor triggers ?
- Zo Kath Ra
- Posts: 944
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Floor trigger and flying monsters
EDIT: My bad, I didn't see that the line that creates a connector isn't a function. Do I understand it well if I think that those lines that add onEndAction connectors are computed on game start ? But what about dynamically created monsters ? What would happen if a monster is created after the game start ?
Here is the code part I'm speaking of (from Isaac) :
Here is the code part I'm speaking of (from Isaac) :
Code: Select all
--trigger script (works on specific monsters; checks position and elevation.)
do --Add additional monster ids to the monster table.
local monster = {"crowern_1"}
for x = 1, #monster do
findEntity(monster[x]).move:addConnector('onEndAction', self.go.id, 'triggerFunction')
end
end
function triggerFunction(target)
if target.go.x == self.go.x and target.go.y == self.go.y and target.go.elevation == self.go.elevation then
--Do something when triggered
playSound("secret")
hudPrint(target.go.id.." (a "..target.go.name.."), has triggered the function.")
--
end
end
Re: Floor trigger and flying monsters
The initial loop adds the connector to each monster in the monster table. For any newly spawned monsters, one need only add the connector manually when spawned.
Example: [Untested! ~but it should work barring typo]
Example: [Untested! ~but it should work barring typo]
Code: Select all
spawn("crowern").move:addConnector('onEndAction', <the script id you've used> , 'triggerFunction')