Trigger Events when typing
Last updated
Last updated
Events are special tags that let you send messages (string) to any listener script, once the typewriter has reached a specific part of the text. (For this reason, events work only if the typewriter is enabled)
You can write events in your text by using rich text tags.
Eventβs messages are preceded by a question mark, like this: <?eventMessage>
.
Example: To call an event named βshakeCameraβ, write: <?shakeCamera>
ππ» An event can have any kind of tag, including built-in effectβs ones.
β οΈ Events are case sensitive. Writing <?camshake>
is not the same as writing <?camShake>
. Be careful! (or use the string.ToLower()
method in your scripts to account for that.)
Events can have one or multiple parameters (starting with the =
sign for the first, and then separating the others with a comma ,
), to allow you to send multiple data to your scripts.
One parameter: <?eventID=parameter1>
, will result in a message βeventIDβ and one parameter βparameter1β.
Multiple parameters: <?eventID=p1,p2>
, will result in a message βeventIDβ and parameters βp1β and βp2β.
The scripts that you want to listen from events/messages must subscribe to the onMessage
callback inside the Typewriter
class. (Scripting Api).
Example:
ππ» Note how the βmessageβ string has no β<β, β?β and β>β characters, but only contains the message.
You can find the EventMarker API here, for example to get all the parameters of the event (if any).