summary refs log tree commit diff stats
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/scripts/common.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 2e6a7e2..4dfa1a2 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -32,12 +32,17 @@ SpriteLayer = {
32 32
33gamestate = {} 33gamestate = {}
34 34
35--- Yields until the specified amount of time has passed.
36-- @param time in milliseconds
35function Delay(time) 37function Delay(time)
36 while time > 0 do 38 while time > 0 do
37 time = time - coroutine.yield() 39 time = time - coroutine.yield()
38 end 40 end
39end 41end
40 42
43--- Starts a cutscene.
44-- This takes care of showing the cutscene bars, as well as halting character
45-- movement. It does not block.
41function StartCutscene() 46function StartCutscene()
42 local playerId = getPlayerSprite() 47 local playerId = getPlayerSprite()
43 local playerSprite = getSprite(playerId) 48 local playerSprite = getSprite(playerId)
@@ -46,24 +51,42 @@ function StartCutscene()
46 message():displayCutsceneBars() 51 message():displayCutsceneBars()
47end 52end
48 53
54--- Queues a message for display.
55-- Non-blocking! If you want to block until the message has been fully
56-- revealed, use WaitForEndOfMessage().
57-- @param msg the text of the message
58-- @param name the name of the character speaking (leave blank to not show a character name)
59-- @param type the SpeakerType for the character, which determines which beep sound is played, if any
49function DisplayMessage(msg, name, type) 60function DisplayMessage(msg, name, type)
50 message():displayMessage(msg, name, type) 61 message():displayMessage(msg, name, type)
51end 62end
52 63
64--- Queues a choice prompt for the player.
65-- This should be called after DisplayMessage(), as it is not valid for a choice
66-- prompt to be the first line of the text box. This also does not block. You
67-- should use WaitForEndOfMessage() after this.
68-- @param one the text of the first option
69-- @param two the text of the second option
53function ShowChoice(one, two) 70function ShowChoice(one, two)
54 message():showChoice(one, two) 71 message():showChoice(one, two)
55end 72end
56 73
74--- Gets the result of the last choice prompt.
75-- @return 0 for the left choice, 1 for the right choice
57function GetChoiceSelection() 76function GetChoiceSelection()
58 return message():getChoiceSelection() 77 return message():getChoiceSelection()
59end 78end
60 79
80--- Yields until all queued messages / choice prompts have been dismissed.
81-- This does not hide the cutscene bars, nor does it wait for them to hide.
61function WaitForEndOfMessage() 82function WaitForEndOfMessage()
62 while (message().isMessageActive) do 83 while (message().isMessageActive) do
63 coroutine.yield() 84 coroutine.yield()
64 end 85 end
65end 86end
66 87
88--- Hides the cutscene bars.
89-- This also re-enables player movement.
67function HideCutsceneBars() 90function HideCutsceneBars()
68 WaitForEndOfMessage() 91 WaitForEndOfMessage()
69 message():hideCutsceneBars() 92 message():hideCutsceneBars()