summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-07-05 12:05:47 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2021-07-05 12:05:47 -0400
commitb57aa99e101c7cf59fd59d2f8df9fe3547d91acc (patch)
tree24fe75aa7128944227bcd053b92fb89ade4f580c
parent324346a87c114f0991a092ac8653afecada364b5 (diff)
downloadtanetane-b57aa99e101c7cf59fd59d2f8df9fe3547d91acc.tar.gz
tanetane-b57aa99e101c7cf59fd59d2f8df9fe3547d91acc.tar.bz2
tanetane-b57aa99e101c7cf59fd59d2f8df9fe3547d91acc.zip
Made the "everyone looks at mirror" behaviour into a background script
This simplifies it a bit, because it no longer needs to constantly check that we are on the right map. It is linked to the mirror's edge.
-rw-r--r--res/maps/hallucination_mirror.tmx1
-rw-r--r--res/scripts/hallucination_mirror.lua11
2 files changed, 6 insertions, 6 deletions
diff --git a/res/maps/hallucination_mirror.tmx b/res/maps/hallucination_mirror.tmx index eeeb718..2f2c580 100644 --- a/res/maps/hallucination_mirror.tmx +++ b/res/maps/hallucination_mirror.tmx
@@ -117,6 +117,7 @@
117 <object id="11" name="mirror_sight" type="zone" x="176" y="128" width="176" height="48"/> 117 <object id="11" name="mirror_sight" type="zone" x="176" y="128" width="176" height="48"/>
118 <object id="12" name="mirror_edge" type="sprite" x="176" y="112"> 118 <object id="12" name="mirror_edge" type="sprite" x="176" y="112">
119 <properties> 119 <properties>
120 <property name="backgroundScript" value="look_at_mirror"/>
120 <property name="collisionHeight" type="int" value="16"/> 121 <property name="collisionHeight" type="int" value="16"/>
121 <property name="collisionOffsetX" type="int" value="0"/> 122 <property name="collisionOffsetX" type="int" value="0"/>
122 <property name="collisionOffsetY" type="int" value="0"/> 123 <property name="collisionOffsetY" type="int" value="0"/>
diff --git a/res/scripts/hallucination_mirror.lua b/res/scripts/hallucination_mirror.lua index afacd59..18a3e28 100644 --- a/res/scripts/hallucination_mirror.lua +++ b/res/scripts/hallucination_mirror.lua
@@ -1,19 +1,18 @@
1hallucination_mirror = {} 1hallucination_mirror = {}
2 2
3function hallucination_mirror.init() 3function hallucination_mirror.look_at_mirror()
4 coroutine.yield() 4 coroutine.yield()
5 -- This routine makes the player's party face the mirror if they are standing 5 -- This routine makes the player's party face the mirror if they are standing
6 -- in front of it for a few (5) seconds. The fact that this has to run 6 -- in front of it for a few (5) seconds. The fact that this has to run
7 -- continuously makes it a bit complicated, and is why we keep checking that 7 -- continuously makes it a bit complicated.
8 -- we're on the same map. 8 while true do
9 while getMap():getName() == "hallucination_mirror" do
10 if IsSpriteInZone("lucas", "mirror_sight") and IsSpriteInZone("kuma", "mirror_sight") and IsSpriteInZone("duster", "mirror_sight") and IsSpriteInZone("boney", "mirror_sight") then 9 if IsSpriteInZone("lucas", "mirror_sight") and IsSpriteInZone("kuma", "mirror_sight") and IsSpriteInZone("duster", "mirror_sight") and IsSpriteInZone("boney", "mirror_sight") then
11 timer = 5000 -- milliseconds 10 timer = 5000 -- milliseconds
12 while timer > 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" and not message().isMessageActive do 11 while timer > 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and not message().isMessageActive do
13 timer = timer - coroutine.yield() 12 timer = timer - coroutine.yield()
14 end 13 end
15 14
16 if timer <= 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" and not message().isMessageActive then 15 if timer <= 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and not message().isMessageActive then
17 SetPartyDirection(getPlayerSprite(), Direction.UP) 16 SetPartyDirection(getPlayerSprite(), Direction.UP)
18 end 17 end
19 end 18 end