Skip to content

Scripts

SG edited this page May 31, 2021 · 14 revisions

Scripts are little bits of dialog and behavior that happen when the player bumps into a sprite, enters or leaves a room, or starts the game. Any plain text you write in the script will be printed in a little dialog box in the game, but there are also special codes you can use to format the text, change features of rooms or sprites, or do something only when a certain condition is met (like collecting enough items).

Jump to scripts for...

Terms

Expression

Returns some value, that can be inserted into the dialog text or used as an argument in another function or expression. Think of this as the verb of a sentence. Expressions are written with curly braces: {sprite-name}

Function

Performs some action in the game or affects the dialog. Functions don't return values though, so you can't use them as arguments in other functions or expressions. Like an expression, you can think of this as the verb of a sentence. Functions are also written with curly braces: {remove-sprite}

Argument

A bit of information you give to an expression or function to tell it what to do. Think of these as the subjects and objects of a sentence. Arguments get written after the name of the expression/function, separated by spaces: {move-avatar "room-1-2" 0 5}

Num

An integer (no floats/decimals) or an expression that returns a number.

Str

A string/bit of text or an expression that returns a string. If you want to include spaces in your string (or you just feel like it) you can enclose it in double-quotes.

Bool

A boolean ("true" or "false") or an expression that returns a boolean.

Expressions and Functions

Dialog

[some text]

If you write plain text into the script box, it will show up as dialog in the game.

{b}

A function that inserts a line break.

Example: line one{b}line two

{p}

A function that inserts a page break.

Example: page one{p}page two

{wavy} ... {/wavy}

A function that transforms the text between the opening and closing tags into animated, wavy text.

Example: {wavy}whoa so cool!{/wavy}

{shaky} ... {/shaky}

A function that transforms the text between the opening and closing tags into animated, shaky text.

Example: {shaky}spooky scary skeletons{/shaky}

{color [num]} ... {/color}

A function that colors the text between the opening and closing tags with the specific number from the current room's color palette (0 = background color, 1 = first foreground color, etc).

Example: {color 1}some colorful text{/color}

{position [top/center/bottom/fullscreen]} ... {/position}

A function that specifies where the dialog box should be shown on the screen.

Example: {position center}a dialog box in the middle of the screen{/position}

Example: {position fullscreen}a full-screen title card{/position}

{delay [num]}

A function that waits a number of frames before continuing with the script.

Example: huh...{delay 5} I didn't think that would work

World

{world-name}

An expression that returns the world's name.

Example: welcome to the world of {world-name}

Avatar

{avatar-name}

An expression that returns the name of the avatar's sprite.

Example: the avatar is called {avatar-name}

{avatar-x}

An expression that returns the x position (column number) of the avatar, starting with 0.

Example: you're at column {avatar-x}

{avatar-y}

An expression that returns the y position (row number) of the avatar, starting with 0.

Example: you're at row {avatar-y}

{move-avatar [optional: room name] [x] [y]}

A function that moves the avatar to the specific room and x, y position. If no room is specified, use the room they're already in.

Example: {move-avatar 0 15}

Example: {move-avatar room-1-2 0 15}

{transform-avatar [sprite name]}

A function that changes the appearance of the avatar to look like the given sprite.

Example: {transform-avatar wall}

Sprite

{sprite-room}

An expression that returns the name of the room that the current sprite is in. (Only available in sprite scripts.)

Example: this sprite lives in {sprite-room}

{sprite-x}

An expression that returns the x position (column number) of the current sprite, starting with 0. (Only available in sprite scripts.)

Example: this sprite is column {sprite-x}

{sprite-y}

An expression that returns the y position (row number) of the current sprite, starting with 0. (Only available in sprite scripts.)

Example: this sprite is on row {sprite-y}

{sprite-name}

An expression that returns the name of the current sprite. (Only available in sprite scripts.)

Example: hello, my name is {sprite-name}

{sprite-wall}

An expression that returns "true" if the current sprite is a wall. (Only available in sprite scripts.)

Example: {if {sprite-wall}}you shall not pass!{/if}

{sprite-item}

An expression that returns "true" if the current sprite is an item. (Only available in sprite scripts.)

Example: {if {sprite-item}}eat me{/if}

{move-sprite [optional: room name] [x] [y]}

A function that moves the current sprite to the specific room and x, y position. If no room is specified, use the room they're already in. (Only available in sprite scripts.)

Example: {move-sprite 0 5}

Example: {move-sprite room-1-2 0 5}

{place-sprite [sprite name] [optional: room name] [x] [y]}

A function that adds a sprite to the given room at a specific x, y position. If no room is specified, use the room they're already in.

Example: {place-sprite teacup 0 5}

Example: {place-sprite teacup room-1-2 0 5}

{transform-sprite [sprite name]}

A function that changes the current sprite into the given sprite. (Only available in sprite scripts.)

Example: {transform-sprite teacup}

{remove-sprite}

A function that removes the current sprite from its current location. (Only available in sprite scripts.)

Example: {remove-sprite}

{set-sprite-color [num]}

A function that changes the color palette index of the current sprite (0 = background color, 1 = first foreground color, etc). (Only available in sprite scripts.)

Example: {set-sprite-color 2}

{set-sprite-wall [bool]}

A function that changes whether the current sprite is a wall. (Only available in sprite scripts.)

Example: {set-sprite-wall false}

{set-sprite-item [bool]}

A function that changes whether the current sprite is an item. (Only available in sprite scripts.)

Example: {set-sprite-item true}

Room

{room-name}

The name of the current room (ie. the room the avatar is in)

Example: this is room {room-name}

{empty [x] [y]}

An expression that returns whether there is a sprite at the given location.

Example: {if {is-empty 5 8}}{place-sprite teacup 5 8}{/if}

{set-palette [optional: room name] [palette name]}

A function that sets the palette of the current or given room.

Example: {set-palette palette-2}

Example: {set-palette room-1-2 palette-2}

{set-music [optional: room name] [music name]}

A function that sets the music of the current or given room.

Example: {set-music song-2}

Example: {set-music room-1-2 song-2}

Math

{add [num] [num]}

An expression that adds the arguments together.

Example: {add 5 4} is equal to 9

{sub [num] [num]}

An expression that subtracts the second argument from the first argument.

Example: {sub 5 4} is equal to 1

{mul [num] [num]}

An expression that multiplies the arguments together.

Example: {mul 5 4} is equal to 20

{div [num] [num]}

An expression that divides the first argument by the second argument.

Example: {mul 20 4} is equal to 5

{mod [num] [num]}

An expression that returns the first argument modulo the second argument.

Example: {mul 5 4} is equal to 1

{random [num] [num]}

An expression that returns a random number between the first and second argument (inclusive).

Example: {random 1 4} could be 1, 2, 3, or 4

Comparison & Logic

{if [bool]} ... {else} ... {/if}

A function that only displays the dialog (or run the functions) between the opening and closing tags if the argument is true.

You can also include an {else} in the middle to display or do something else if the argument is false.

Example: to be {if {eq 2 8}}or not to be{/if}

Example: {if {lt {item-count crow} 10}} you need to befriend more crows {else} oh no... it's a murder! {/if}

{eq [num/str/bool] [num/str/bool]}

An expression that returns "true" if the two arguments are equal to each other.

Example: {eq 5 5} is true

Example: {eq "something" "something else"} is false

{gt [num] [num]}

An expression that returns "true" if the first argument is greater than the second one.

Example: {gt 5 4} is true but {gt 5 5} is false

{gte [num] [num]}

An expression that returns "true" if the first argument is greater than or equal to the second one.

Example: {gte 5 4} and {gte 5 5} are both true

{lt [num] [num]}

An expression that returns "true" if the first argument is less than the second one.

Example: {lt 5 6} is true but {lt 5 5} is false

{lte [num] [num]}

An expression that returns "true" if the first argument is less than or equal to the second one.

Example: {lte 5 6} and {lte 5 5} are both true

{not [bool]}

An expression that returns "true" if the argument is false, and "false" if the argument is true.

Example: {not {eq 5 5}} is false, and {not {eq 5 4}} is true

{all-true [bool] [bool] ... [bool]}

An expression that returns "true" only if every argument is true.

Example: {all-true true true} is true but {all-true true false} is false

{any-true [bool] [bool] ... [bool]}

An expression that returns "true" if any argument is true.

Example: {any-true true true} and {any-true true false} are true

{none-true [bool] [bool] ... [bool]}

An expression that returns "true" if none of the arguments are true.

Example: {none-true true false} is false but {none-true false false} is true

Variables

{var [variable name]}

An expression that returns the value of a variable, if that variable has been set.

Example: you have collected {var hearts} hearts

{set-var [variable name] [num/str/bool]}

A function that sets the given variable to a new value (a number, string, or boolean).

Example: {set-var hearts 100}

{inc-var [variable name] [optional: num]}

A function that increments the given variable (adds one to its value, if it's a number). Optionally, you can add a second argument to increment by a larger number.

Example: {inc-var hearts}

Example: {inc-var hearts 10}

{dec-var [variable name] [optional: num]}

A function that decrements the given variable (subtracts one from its value, if it's a number). Optionally, you can add a second argument to decrement by a larger number.

Example: {dec-var hearts}

Example: {dec-var hearts 10}

Items

{item-count [item name]}

An expression that returns the number of items in the player's inventory.

Example: I only have {item-count teacup} teacups left

{set-item-count [item name] [num]}

A function that sets the number of the given item in the player's inventory (minimum 0).

Example: {set-item-count teacup 5}

{inc-item-count [item name] [optional: num]}

A function that adds one of the given item to the player's inventory. Optionally, you can add a second argument to add more than one item at a time.

Example: {inc-var teacup}

Example: {inc-var teacup 5}

{dec-item-count [item name] [optional: num]}

A function that removes one of the given item to the player's inventory (down to 0). Optionally, you can add a second argument to add more than one item at a time.

Example: {dec-var teacup}

Example: {dec-var teacup 5}

Selecting Sprites

{pick [sprite expression]} ... {/pick}

A function that changes which sprite is targeted for functions and expressions like "remove-sprite" and "sprite-name". If the sprite expression refers to multiple sprites, the contents of this expression are run for every sprite in that list.

{sprite-at [x] [y]}

An expression that returns the sprite(s) at the given coordinates in the current room.

Example: {pick {sprite-at 3 4}}{remove-sprite}{/pick}

{sprites-in-room}

An expression that returns all sprites in the current room.

Example: {pick {sprites-in-room}}{if {sprite-wall}}{remove-sprite}{/if}{/pick}

{sprites-named [sprite name]}

An expression that returns all sprites in the current room with the given name.

Example: {pick {sprites-named bud}}{transform-sprite flower}{/pick}

{neighbors}

An expression that returns all sprites adjacent to the current sprite.

Example: {pick {neighbors}}hello, {sprite-name}! {/pick}

Clone this wiki locally