diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-18 18:57:37 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-18 18:57:37 -0500 |
commit | ecaae697a8bffc50a5a9ff033bbb7827be826e5e (patch) | |
tree | caa4810e165ff8e9bfd1ae42707ac0e3a46f47fa /res/scripts | |
parent | 027166a0efa4b91b4c400ef253a4b51dcea8cb6c (diff) | |
download | tanetane-ecaae697a8bffc50a5a9ff033bbb7827be826e5e.tar.gz tanetane-ecaae697a8bffc50a5a9ff033bbb7827be826e5e.tar.bz2 tanetane-ecaae697a8bffc50a5a9ff033bbb7827be826e5e.zip |
Added documentation to the message-related script functions
Diffstat (limited to 'res/scripts')
-rw-r--r-- | res/scripts/common.lua | 23 |
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 | ||
33 | gamestate = {} | 33 | gamestate = {} |
34 | 34 | ||
35 | --- Yields until the specified amount of time has passed. | ||
36 | -- @param time in milliseconds | ||
35 | function Delay(time) | 37 | function 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 |
39 | end | 41 | end |
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. | ||
41 | function StartCutscene() | 46 | function 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() |
47 | end | 52 | end |
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 | ||
49 | function DisplayMessage(msg, name, type) | 60 | function DisplayMessage(msg, name, type) |
50 | message():displayMessage(msg, name, type) | 61 | message():displayMessage(msg, name, type) |
51 | end | 62 | end |
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 | ||
53 | function ShowChoice(one, two) | 70 | function ShowChoice(one, two) |
54 | message():showChoice(one, two) | 71 | message():showChoice(one, two) |
55 | end | 72 | end |
56 | 73 | ||
74 | --- Gets the result of the last choice prompt. | ||
75 | -- @return 0 for the left choice, 1 for the right choice | ||
57 | function GetChoiceSelection() | 76 | function GetChoiceSelection() |
58 | return message():getChoiceSelection() | 77 | return message():getChoiceSelection() |
59 | end | 78 | end |
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. | ||
61 | function WaitForEndOfMessage() | 82 | function WaitForEndOfMessage() |
62 | while (message().isMessageActive) do | 83 | while (message().isMessageActive) do |
63 | coroutine.yield() | 84 | coroutine.yield() |
64 | end | 85 | end |
65 | end | 86 | end |
66 | 87 | ||
88 | --- Hides the cutscene bars. | ||
89 | -- This also re-enables player movement. | ||
67 | function HideCutsceneBars() | 90 | function HideCutsceneBars() |
68 | WaitForEndOfMessage() | 91 | WaitForEndOfMessage() |
69 | message():hideCutsceneBars() | 92 | message():hideCutsceneBars() |