From b3c8a3ab263e2312a35ef68ffb56217eeb619803 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 28 Feb 2021 10:15:19 -0500 Subject: Added time passage mailbox event --- res/scripts/common.lua | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'res/scripts/common.lua') 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 = { } ChangeMapOptions = { - DO_NOT_FADE = 1 -- Prevents fading to and from black + DO_NOT_FADE = 1, -- Prevents fading to and from black + DO_NOT_CHANGE_MUSIC = 2 -- Prevents stopping or starting music as part of the map change } PathfindingOptions = { @@ -289,10 +290,12 @@ function ChangeMap(map, warp, options) loadMap(map) character():transplantParty(playerId, getMap():getWarpPoint(warp), direction) - if (mixer():isPlayingMusic() and not getMap():hasMusic()) then - mixer():fadeoutMusic(150) - elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then - mixer():playMusic(getMap():getMusic(), 150) + if (options & ChangeMapOptions.DO_NOT_CHANGE_MUSIC == 0) then + if (mixer():isPlayingMusic() and not getMap():hasMusic()) then + mixer():fadeoutMusic(150) + elseif (getMap():hasMusic() and (not mixer():isPlayingMusic() or not (mixer():getPlayingTrack() == getMap():getMusic()))) then + mixer():playMusic(getMap():getMusic(), 150) + end end coroutine.yield() @@ -413,3 +416,34 @@ function WaitForSpritePath(spriteName) coroutine.yield() end end + +--- Fades out the currently playing music. +-- This does not block. If you want it to block, call Delay for the same amount +-- of time. +-- @param length the fadeout time in milliseconds +function FadeoutMusic(length) + mixer():fadeoutMusic(length) +end + +--- Plays the specified track. +-- @param song the name of the song to play +-- @param length the time in milliseconds to fade in. if left blank, the track starts immediately +function PlayMusic(song, length) + length = length or 0 + + mixer():playMusic(song, length) +end + +--- Makes the player sprite non-controllable. +function DisablePlayerControl() + local playerId = getPlayerSprite() + local playerSprite = getSprite(playerId) + playerSprite.controllable = false +end + +--- Makes the player sprite controllable again. +function EnablePlayerControl() + local playerId = getPlayerSprite() + local playerSprite = getSprite(playerId) + playerSprite.controllable = true +end -- cgit 1.4.1