M22 Script API Reference - Slynchy/March22-Unity GitHub Wiki

NewPage

Clears the current page of text and goes to the next line. Narrative/novel mode only.

Usage

This is the start of a page 
This is too
NewPage
Now we are on a new page again!

DrawBackground ( _backgroundName, _Xoffset, _Yoffset, _wScale, _hScale, _instant )

Draws the specified background, with the following parameters as modifiers:

Parameter Description
_backgroundName Filename of desired background under "Resources/Backgrounds". String.
_Xoffset How much to offset the background horizontally. Integer.
_Yoffset How much to offset the background vertically. Integer.
_wScale How much to scale the background horizontally, where 1.0 is the default size. Float.
_hScale How much to scale the background vertically, where 1.0 is the default size. Float.
_instant Jump to next line immediately or wait until the animation is complete? Boolean.

Usage

This is some dialogue
DrawBackground snowy_background
We are now in a snowy area!
DrawBackground desert_background true
While I am speaking, we have now entered the desert!
DrawBackground desert_background 300 0 1.0 1.0 true
We can also do moving backgrounds by changing the X offset only!

PlayMusic ( _trackName )

Fades in and plays on loop the specified track from "Resources/Music"

Parameter Description
_trackName Filename of desired music under "Resources/Music". String.

Usage

Some dialogue here. 
character "This is some character dialogue!"
PlayMusic sad_music
character "Aw I'm depressed now."

StopMusic ( _speed )

Fades out and stops active music playing.

Parameter Description
_speed Speed multiplier for fading out, where 1.0 is default. Float.

Usage

PlayMusic sad_music
character "Aw I'm depressed now."
StopMusic 0.66
character "Uh oh, the music has stopped?"

PlaySting ( _filename )

Plays a one-shot SFX from the Resources folder.

Parameter Description
_filename Filename of desired SFX under "Resources/SFX". String.

Usage

PlaySting ominous_eery_noise
character "Oh dear, how ominous and eery!"

HideWindow

Hides the textbox with a very quick fade-out.

Usage

We have some dialogue here.
    HideWindow
    DrawBackground new_bg
    ShowWindow
What we just did is hid the window while the background was changing!

ShowWindow

Shows the textbox with a very quick fade-in.

Usage

We have some dialogue here.
    HideWindow
    DrawBackground new_bg
    ShowWindow
What we just did is hid the window while the background was changing!

DrawCharacter ( _characterName, _emotion, _Xoffset, _newLine )

Draws the specified character on screen. Intended for use in VN mode. Used with the following parameters as modifiers:

Parameter Description
_characterName Name of character from "Resources/Characters". String.
_emotion Emotion of character to draw from "Resources/Characters/CharName". String.
_Xoffset How much to offset the character horizontally. Integer.
_newLine Go to the next line immediately or wait until the character has faded in? Boolean.

Usage

This is some dialogue
DrawCharacter newchar an_emotion
newchar is now on screen!
DrawCharacter newchar a_new_emotion
newchar now has a different face!
DrawCharacter newchar a_new_emotion 200
newchar is now 200 pixels to the right!
DrawCharacter newchar a_new_emotion -200 true
newchar is moving while I'm talking!

Transition ( _background, _transition, _inOrOut, _speed )

Transitions to the specified background using the specified grayscale transition file.

Parameter Description
_background Name of background from "Resources/Backgrounds". String.
_transition Name of grayscale transition image from "Resources/Transitions". String.
_inOrOut Is the transition fading in or out? "in" for in, "out" for out.
_speed Speed of the animation. Float. Optional.

Usage

We're going to show the passage of time by fading to black.
    Transition black tr-delayblinds in
// And then back to normal!
    Transition new_bg tr-delayblinds out 2.0
And done!

ClearCharacters

Clears the screen of all characters currently visible.

Usage

DrawCharacter char_1 emote_1 300 true
DrawCharacter char_2 emote_1 -300 true
DrawCharacter char_3 emote_1 600
Oh dear, too many characters!
ClearCharacters
All gone!

ClearCharacter ( _charName, _newLine )

Clears the specified character off the screen.

Parameter Description
_charName Name of character, from "Resources/Characters". String.
_newLine Jump to the next line immediately or wait until the character is faded out? Boolean.

Usage

DrawCharacter char_1 emote_1 300 true
me "Oh hello, Mr char_1!"
ClearCharacter char_1 true
me "Oh, goodbye I guess?"

ExecuteFunction ( _funcName )

Executes the specified custom function.

Parameter Description
_funcName The name of the custom function to call. Refer to custom function documentation.

Usage

DrawBackground snowy_day
ExecuteFunction snow_effect
Oh, it's snowing!

Goto ( _checkpointName )

Jumps straight to the specified checkpoint.

Parameter Description
_checkpointName Name of checkpoint to jump to. Refer to checkpoint guidance.

Usage

--chkpnt1
    This is checkpoint 1.
    But we don't want to be here, we want to go to chkpnt 3.
    Goto chkpnt3
--chkpnt2
    This is checkpoint 2.
    This won't get seen because we're skipping it!
--chkpnt3
    This is checkpoint 3.

Wait ( _waitTime )

Jumps straight to the specified checkpoint.

Parameter Description
_waitTime Amount of time to wait in milliseconds. Integer.

Usage

This is some dialogue.{{Wait 500}} And here's some more!
Or alternatively...
Wait 230
You can wait between lines too!

EnableNovelMode/DisableNovelMode

Enables/disables "novel mode", where the text box covers the screen and new lines are presented below the last.

Usage

EnableNovelMode
Now my character can do a big monologue.
There's no character naming here, as it's intended for narrative only.
DisableNovelMode
char "Back to normal!"

MakeDecision ( _choice1TXT, _choice1Flag, _choice2TXT, _choice2Flag, _choice3TXT, _choice3Flag )

Presents the decision prefab to the player, with the specified choices.

Parameter Description
_choice1TXT The text to show the player for choice 1. String, surround with quote marks ("").
_choice1Flag Flag to set if the player picks this choice. String.
_choice2TXT The text to show the player for choice 2. String, surround with quote marks ("").
_choice2Flag Flag to set if the player picks this choice. String.
_choice3TXT The text to show the player for choice 3. String, surround with quote marks (""). Optional.
_choice3Flag Flag to set if the player picks this choice. String. Optional.

Usage

Let's give the player a choice.
MakeDecision "Why?" choiceA1_1 "Yeah, of course." choiceA1_2
    // Now one of these flags will be true, so we can check which with an IF statement.
m22IF choiceA1_1 Goto chapter2
m22IF choiceA1_2 Goto chapter2b

m22IF ( _flagName, _functionIfTrue )

Checks the specified flag. If true, it runs the function. Otherwise, continues to the next line.

Parameter Description
_flagName Name of the flag to check. String.
_functionIfTrue Function to run if the flag is true. String.

Usage

// For debug purposes, let's set a flag secretly.
SetFlag testFlag
// Now let's test the flag.
m22IF asdfasdf Goto chapter2
    // This will return false, so it'll fall to the next line.
m22IF testFlag This can also be dialogue! Or speech! Whatever you need!

SetFlag ( _flagName )

Sets the specified flag to true.

Parameter Description
_flagName The name of the flag to set to true. String.

Usage

The "SetFlag" function is intended for debug purposes, but it has uses besides debugging.
SetFlag rubbishDeveloper
Now we can check that flag easily.
m22IF rubbishDeveloper Oi, that's not very nice.

LoadScript ( _fileName )

Unloads loaded assets and compiles/loads the specified script.

Parameter Description
_fileName The path to the script file, starting from "Resources/". String.

Usage

me "This script file is getting awwwwfully long!"
me "You might even crash someone's device with this much dialogue."
me "Not the mention all the loaded assets!"
you "Oh no, what can I do?!"
LoadScript new_script_file
This dialogue will never be seen because it is after the LoadScript function!

PlayVideo ( _fileName )

Plays the specified video file under "Resources/Videos". Must be in Unity-friendly format.

Parameter Description
_fileName The path to the video file, starting from "Resources/Videos". String.

Usage

me "Hey, you said you hired an animator, right?"
you "Yeah, he even made an AVI file!"
me "That won't do, it has to be an MP4!"
you "He did that too!"
me "Ah, in that case!"
PlayVideo crappy_animation
me "That was awful."

SetMovementSpeed ( _speed )

Sets the speed of animations, such as character movement or fade-in.

Parameter Description
_speed Speed multiplier for the animations, default "1.0". Float.

Usage

DrawCharacter char_1 emote_1 0 false
me "You came in pretty slowly."
SetMovementSpeed 2.0
DrawCharacter char_1 emote_1 300 false
SetMovementSpeed 3.0
DrawCharacter char_1 emote_1 -300 false
you "How about now? Muahahaha~!"

SetTextSpeed ( _speed )

Sets the speed of the typewriter effect, on the text.

Parameter Description
_speed Speed multiplier for the text, default "1.0". Float.

Usage

I'm very happy!
SetTextSpeed 0.6
Actually...
SetTextSpeed 0.2
I'm sad.

SetAnimationType ( _type )

Sets the type of animation to use for movement or fade-in, for backgrounds or characters.

Parameter Description
_type Type of animation to use, either "Lerp" or "Smooth". String.

Usage

// This one is pretty hard to show an example of
// If you need a scrolling background, Lerp is better
// For characters, Smooth is better
// Make sure to reset it to what you need it to be after use!

PlayLoopedSting ( _file, _volume, _fadeSpeed )

Plays the specified SFX file on loop, at the specified volume, and fades in.

Parameter Description
_file File to load under "Resources/SFX". String.
_volume Volume to play at, default 1.0. Float. Optional.
_fadeSpeed Speed to fadein the SFX at. Float. Optional.

Usage

PlayLoopedSting crowded_room 0.3 1.0
me "Wow this room sure is crowded!"
StopLoopedSting crowded_room 0.4
me "Hm, maybe not."

StopLoopedSting ( _file, _fadeSpeed )

Stops the specified SFX from playing, fading it out at the specified speed.

Parameter Description
_file Sting to stop playing. String.
_fadeSpeed Speed to fade-out the SFX at. Float. Optional.

Usage

PlayLoopedSting crowded_room 0.3 1.0
me "Wow this room sure is crowded!"
StopLoopedSting crowded_room 0.4
me "Hm, maybe not."