summary refs log tree commit diff stats
path: root/res/scripts
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-17 20:34:59 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-17 20:34:59 -0500
commitaac57db782718bf40a7adea15baf8d6b899ea925 (patch)
treec9f32563cdb9a06e6e24343946c5bb35dc254b76 /res/scripts
parentb3720c4a401f345c49eadabdb852968e273e7077 (diff)
downloadtanetane-aac57db782718bf40a7adea15baf8d6b899ea925.tar.gz
tanetane-aac57db782718bf40a7adea15baf8d6b899ea925.tar.bz2
tanetane-aac57db782718bf40a7adea15baf8d6b899ea925.zip
Made some sprites persist between map changes
The player party characters are now initialised at the start of the game and are no longer re-created after every map change. The script system takes care of moving the player into the correct position on the new map.

Deleted sprite IDs are now reused the next time a sprite is created, instead of throwing out everything between maps.
Diffstat (limited to 'res/scripts')
-rw-r--r--res/scripts/common.lua12
1 files changed, 3 insertions, 9 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 8a9445b..2e6a7e2 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -178,21 +178,15 @@ function ChangeMap(map, warp)
178 local playerId = getPlayerSprite() 178 local playerId = getPlayerSprite()
179 local playerSprite = getSprite(playerId) 179 local playerSprite = getSprite(playerId)
180 local direction = playerSprite.dir 180 local direction = playerSprite.dir
181 local oldState = playerSprite.characterState
182 181
183 playerSprite.controllable = false 182 playerSprite.controllable = false
184 FadeToBlack(150) 183 FadeToBlack(150)
185 loadMap(map, warp, direction) 184 loadMap(map)
186 185 character():transplantParty(playerId, getWarpPoint(warp), direction)
187 local newPlayerId = getPlayerSprite()
188 local newPlayerSprite = getSprite(newPlayerId)
189 if oldState == CharacterState.RUNNING then
190 character():startRunning(newPlayerId)
191 end
192 186
193 coroutine.yield() 187 coroutine.yield()
194 RemoveFadeout(150) 188 RemoveFadeout(150)
195 newPlayerSprite.controllable = true 189 playerSprite.controllable = true
196end 190end
197 191
198function CreateAnimatedSpriteAtPosition(alias, character, x, y, animName, direction, layer) 192function CreateAnimatedSpriteAtPosition(alias, character, x, y, animName, direction, layer)