Skip to content

Script syntax

eugeniusfox edited this page Apr 12, 2017 · 4 revisions

It's a subset of the Ren'Py script syntax, with the addition of named choices and placeholders. Placeholders comes in two flavours: Reference and Condition.

Dialogue lines

Dialogue lines are simply lines with quoted text that may or may not be preceded by a tag (which in Ren'Py indicates the character who is talking).

me "The line spoke by me."
"A line spoken by the Void."

label, jump, call, and return

Top-level blocks can only be definitions or label blocks; by default, execution starts from the label named start.

The only purpose of a label block is to be the target of a jump or call statement, both of which allow to switch from the current to another label block. The call statement takes the execution flow back to the line it precedes as soon as the target block is exhausted.

The return statement ends the iteration over the script.

label start:
    me "First line."
    call intermission
    me "She was right, I'm back here!"
    jump no_way_back
    her "(Something that won't ever be heard.)"

label intermission:
    her "As soon as I'm done talking, you'll get back to the block that had the audacity to call me."

label no_way_back:
    me "So here we are..."
    return
    me "Wait! I forgot to say... too late."

define

[New in v. 0.9.0-beta] A definition associates an alias to a string, to be used in string interpolation. Definitions can only be top-level statements (i.e., they can't be used inside of label blocks). Numeric values can be assigned without double quotes but are still stored as strings. The strings thus defined can be accessed and edited at runtime via the Globals property of Script (of type Dictionary<string,string>). The strings are interpolated at runtime.

define favorite_color = "red"
define number = 6.2

label start:
    me "My favorite color is [favorite_color]!"

Recursive interpolation is allowed:

define color = "red"
define item = "[color] pen"
define sentence = "The [item] is on the table."

You can't nest aliases (that would imply a support for dynamic aliases), therefore the following would be invalid: "[[prefix][suffix]]".

if, elif, else, and while

Flow control statements work as you'd expect (elif is Python's else if); the condition is a placeholder tag that must correspond to a method in your game logic.

As in Ren'Py, there is no break statement.

label start:
    while FiftyFifty:
        if TheNightIsDark:
            me "The night is dark and full of terrors!"
        elif TheSunShinesBright:
            me "Too hot..."
        else:
            me "As far as I can tell, I'm in the void of darkness where we cry without sound."

Let's be thorough... In the example above, the block repeats itself as long as FiftyFifty evaluates to true. Depending on how TheNightIsDark and TheSunShinesBright evaluate, only one of the lines gets read per iteration.

menu

A menu block can only contain choices, which are like dialogue lines except they end with a colon and can be conditional (i.e., they may or may not be available based on the evaluation of the corresponding condition).

In Ren'Py you can't tag choices as you do dialogue lines.

label start:
    menu:
        "I could to this.":
            me "Done!"
        "Or this." if TheSunShinesBright:
            me "Done, thanks to the shining of the Sun."
        tag "Or even that!":
            me "Done!"

In the example above, were TheSunShinesBright to evaluate to false, the menu would only show the other two options.

References

References are placeholder tags that are bound to actions. By default, the action is run on evaluation.

This loosely corresponds to in-line python expressions in Ren'Py.

label start:
    DoSomething

Comments and pass

Comments behave as in Python. The pass statement is ignored.

label start:
    # Some critical note by the author
    me "This is the only thing actually happening."
    pass