diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-28 10:15:19 -0500 | 
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-28 10:15:19 -0500 | 
| commit | b3c8a3ab263e2312a35ef68ffb56217eeb619803 (patch) | |
| tree | 454ea071f289ae83b5250b133a57ef074de3cbfd /res/scripts/common.lua | |
| parent | 0206fa078e60c0478de6d10376a02377c8574914 (diff) | |
| download | tanetane-b3c8a3ab263e2312a35ef68ffb56217eeb619803.tar.gz tanetane-b3c8a3ab263e2312a35ef68ffb56217eeb619803.tar.bz2 tanetane-b3c8a3ab263e2312a35ef68ffb56217eeb619803.zip  | |
Added time passage mailbox event
Diffstat (limited to 'res/scripts/common.lua')
| -rw-r--r-- | res/scripts/common.lua | 44 | 
1 files changed, 39 insertions, 5 deletions
| diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 123f2a0..8eb491f 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
| @@ -35,7 +35,8 @@ CutsceneOptions = { | |||
| 35 | } | 35 | } | 
| 36 | 36 | ||
| 37 | ChangeMapOptions = { | 37 | ChangeMapOptions = { | 
| 38 | DO_NOT_FADE = 1 -- Prevents fading to and from black | 38 | DO_NOT_FADE = 1, -- Prevents fading to and from black | 
| 39 | DO_NOT_CHANGE_MUSIC = 2 -- Prevents stopping or starting music as part of the map change | ||
| 39 | } | 40 | } | 
| 40 | 41 | ||
| 41 | PathfindingOptions = { | 42 | PathfindingOptions = { | 
| @@ -289,10 +290,12 @@ function ChangeMap(map, warp, options) | |||
| 289 | loadMap(map) | 290 | loadMap(map) | 
| 290 | character():transplantParty(playerId, getMap():getWarpPoint(warp), direction) | 291 | character():transplantParty(playerId, getMap():getWarpPoint(warp), direction) | 
| 291 | 292 | ||
| 292 | if (mixer():isPlayingMusic() and not getMap():hasMusic()) then | 293 | if (options & ChangeMapOptions.DO_NOT_CHANGE_MUSIC == 0) then | 
| 293 | mixer():fadeoutMusic(150) | 294 | if (mixer():isPlayingMusic() and not getMap():hasMusic()) then | 
| 294 | elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then | 295 | mixer():fadeoutMusic(150) | 
| 295 | mixer():playMusic(getMap():getMusic(), 150) | 296 | elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then | 
| 297 | mixer():playMusic(getMap():getMusic(), 150) | ||
| 298 | end | ||
| 296 | end | 299 | end | 
| 297 | 300 | ||
| 298 | coroutine.yield() | 301 | coroutine.yield() | 
| @@ -413,3 +416,34 @@ function WaitForSpritePath(spriteName) | |||
| 413 | coroutine.yield() | 416 | coroutine.yield() | 
| 414 | end | 417 | end | 
| 415 | end | 418 | end | 
| 419 | |||
| 420 | --- Fades out the currently playing music. | ||
| 421 | -- This does not block. If you want it to block, call Delay for the same amount | ||
| 422 | -- of time. | ||
| 423 | -- @param length the fadeout time in milliseconds | ||
| 424 | function FadeoutMusic(length) | ||
| 425 | mixer():fadeoutMusic(length) | ||
| 426 | end | ||
| 427 | |||
| 428 | --- Plays the specified track. | ||
| 429 | -- @param song the name of the song to play | ||
| 430 | -- @param length the time in milliseconds to fade in. if left blank, the track starts immediately | ||
| 431 | function PlayMusic(song, length) | ||
| 432 | length = length or 0 | ||
| 433 | |||
| 434 | mixer():playMusic(song, length) | ||
| 435 | end | ||
| 436 | |||
| 437 | --- Makes the player sprite non-controllable. | ||
| 438 | function DisablePlayerControl() | ||
| 439 | local playerId = getPlayerSprite() | ||
| 440 | local playerSprite = getSprite(playerId) | ||
| 441 | playerSprite.controllable = false | ||
| 442 | end | ||
| 443 | |||
| 444 | --- Makes the player sprite controllable again. | ||
| 445 | function EnablePlayerControl() | ||
| 446 | local playerId = getPlayerSprite() | ||
| 447 | local playerSprite = getSprite(playerId) | ||
| 448 | playerSprite.controllable = true | ||
| 449 | end | ||
