Skip to content

Dialogue, switches and items

A Door on a trigger takes whoever touches it (on its Layers, Player) to its Scene (the level’s exit) or, with no scene, to the entity named in its Target (a teleporter, a door into a house), fading out and in over Fade seconds. Tick Needs Interact and it waits for the Interact action (E, Enter or the gamepad’s Y). Having arrived through one, you have to step off before a door takes you anywhere again, so a pair of portals never sends you back and forth. A door to another scene says where you arrive there with its Arrive At (the door back, so two rooms join both ways; see Doors between scenes). Prompt names an entity (a “Press E” text, its child) that shows only while someone can use it. Needs Flag keeps it shut until a flag is set (MetKing, or not MetKing for while it isn’t): see Flags outside dialogue.

Entity → Story → Dialogue Box makes a panel at the bottom of the screen whose text types itself out, with a portrait and a name tag above it for whoever is talking (see Speakers and portraits). Give a sign or a character a trigger collider and a Dialogue: its Lines (one per row) are said in the box when the player presses Interact beside it, or straight away with Start set to Touch. Interact finishes the line being typed, then shows the next (so does a click or a tap on the game, so a talk can be played with the mouse or on a touch screen); after the last the box hides itself and it sends its Message (TalkedToKing). Pause Game stops everything while it’s said (or, with Pauses naming an entity, only it and everything inside it: see Pausing part of the game), Once says it only the first time, and Prompt works like a door’s. With Start set to Scene Start it starts by itself as the scene starts and needs no collider at all (an intro, a visual novel’s script); once said it isn’t said again until the scene is loaded again. Pause Game stops everything while it’s said (or, with Pauses naming an entity, only it and everything inside it: see Pausing part of the game), Once says it only the first time, and Prompt works like a door’s. The box is hidden while the game runs until someone talks, and a Dialogue Box with a Wrap Width wraps long lines onto more rows. Where a talk has got to (its Is Talking and Line, under State) is saved with the scene, so rewinding in the editor goes back into the middle of it, without doing the lines’ tags again; tick Is Talking and pick a Line to start the game partway through a talk. A dialogue’s Stop action (a button’s Do, a trigger’s) or a script’s Game.EndDialogue(dialogue) ends it at once, even partway through a line, as saying its last line would: the box hides, the pause it held is let go, it’s done (so a Once one isn’t said again), it sends its Message and raises Finished, with its CutShort true so a script can tell a skipped cutscene from one watched through. The rows it didn’t reach aren’t said and their tags aren’t done. That’s a Skip button on a cutscene or a tour. Entity → Edit Dialogue… edits the lines in the Dialogue Editor, a line at a time (see The Dialogue Editor).

A row of Lines starting with > is a choice, offered under the line before it; several in a row are picked between. The player moves between them with the arrow keys, W and S, the D-pad or the stick (the picked one has an arrow by it), or points at one, and picks with Interact, a click or its number key. A choice ending in -> Name goes to the row # Name, which starts a part of the talk that’s only reached that way: the lines before a part end where it starts. A choice with nowhere to go goes on after the choices, a row -> Name goes there by itself, and -> End ends the talk. So a shopkeeper is:

Want a sword?
> Yes -> Buy
> No -> Bye
# Buy
That'll be ten gold.
-> End
# Bye
Safe travels!

Parts can go back to earlier ones, to ask again (the Top-down template’s guide does). Going to a part that isn’t there stops the game as soon as the talk starts, naming it. Start a row with \ to say it as it is, > or # and all.

Flags remember what was said and picked. A row can start with tags in square brackets: [set MetKing] sets a flag and [clear HasKey] clears one when the line is said (or the choice picked), [if MetKing] says the line only when the flag is set and [if not MetKing] only when it isn’t, and [send OpenGate] sends a message, for a gate that opens on one answer and not another. A choice’s tags go after its > (> [if HasKey] Open the vault -> Vault), and it’s only offered while they hold; a go-to with an [if] is only followed while it holds, and a row of tags alone just does them. Choices go under the last line said of those just above them, so two greetings can share them (and when none of those lines is said, neither are the choices). So a king who remembers you is:

[if MetKing] Back again, are we?
[if not MetKing] [set MetKing] Welcome, stranger.
> [if HasKey] I found the key! -> Key
> Farewell -> End
# Key
[clear HasKey] [send OpenVault] Splendid! The vault is yours.

Flags are kept in the game’s save data under their own names, so they’re still set the next time the game runs (Game → Clear Save Data forgets them while you test), until a New Game button forgets them (see New game and carrying on). A flag whose name starts run. (run.Contracts) lasts one run: it’s kept while the game runs and in its saved games, but not written down, so the next time the game starts (or you press Play) it isn’t set, and an unlock doesn’t carry over into the next game. Capitals don’t matter. Scripts read and change them with Game.HasFlag("MetKing") and Game.SetFlag("HasKey") (or SetFlag("HasKey", false)), and a toggle’s Save As is a flag too. A saved game keeps the flags set with dialogue, triggers or SetFlag when it was saved, and loading it puts them back as they were (see Saving and loading); Skip, Auto and a log of the lines said work for any dialogue (see Skip and Auto). Anything else in brackets ([sighs] Fine.) is said as it is.

Give someone a Speaker and their name (its Name, or the entity’s) and Portrait Image show over what their Dialogue says, in the box’s Name Tag and Portrait (named by the box’s Dialogue Box component; each hides when there’s nothing to show, like a sign’s lines). A line starting with a speaker’s name, You: I'll help!, is said by them instead, so the player answers back (give the player a Speaker called You), and a Speaker on an empty entity, even a hidden one, is a narrator or a voice on the radio. A line whose start matches no speaker (Note: ...) is said as it is. Ava (happy): Hi! is said by Ava with that expression: on a visual novel’s stage her face changes (see Visual novels), and scripts read it as the dialogue’s Expression.

Entity → Level → Switch makes a lever. Name what it opens in its Targets (commas between names): while it’s on, a Mover moves (a gate set to Once slides open, and closes again when it’s switched off), a Spawner or Shooter runs, particles emit, an animation plays and a Door unlocks; anything else simply appears. Hides names what disappears while it’s on: a barrier, a wall of spikes. It all starts switched off, so a bridge a lever brings out isn’t there until it’s pulled. Its Mode is Lever (Interact flips it, with a Prompt like a door’s), Plate (on while something on its Layers stands on it: Player, Crate for crates too) or Button (on for good once touched; shoot it by setting Layers to Bullet). On Time turns it off again after that many seconds, for a timed button. It turns its sprite its On Tint (and its On Frame, for a lever drawn both ways), plays its Sound and sends its On Message and Off Message. Set its Beats and it flips itself on the music’s beat as well (see Keeping the beat). Needs Flag stops it being worked until a flag is set (its prompt stays hidden; a trigger’s On still turns it on). If several switches name the same thing, it’s on only while all of them are, so a gate can need two plates held down. Names are looked for inside the switch first, so a prefab can switch its own parts; the Scene view draws a selected switch’s links. What a switch (or a wire into Power) turns on and off is whatever its target’s components mark [Powered], so a script component’s own Running can be switched too.

Anything can set off anything with no code. Components name what they do as actions: a Switch’s On, Off and Toggle, a Door’s Open and Lock, a Spawner’s Spawn, a Shooter’s Fire, a Mover’s Step (to its next point, waiting there for the next), a Health’s Damage, Heal and Kill, a Counter’s Add and Reset, a Turn Order’s End Turn, a Panel’s Open and Close, a match or falling board’s Pause, Resume and Restart (and a match board’s Shuffle), a Move History’s Undo and Restart, a dungeon’s Next Floor, a Dialogue’s Start and Stop, a Sound Player’s Play, and a trigger’s own Set Flag, Clear Flag, Load Scene (to the scene named in its With, fading out and in: Ending once the last talk is over), Play Minigame (the scene named in its With, on top of this one), Win Minigame and Lose Minigame (in a minigame, ending it with a score) and Forget Scene (see Minigames and Scenes that remember), a Minigame’s Play and Stop. Give any entity a Trigger (Gameplay) for each thing it reacts to: when its Message arrives (from anyone, or only From a named entity or something inside it), it does the action in Do on its Targets (on itself without any), With a value for an action that takes one (2 for Damage, MetGuide for Set Flag, Ending for Load Scene), or the message’s own number with Use Message Number (a beat’s count, the points just scored). Do is a list of what its targets can do, flagged in yellow when none of them can; the Inspector shows a line on what it does (“When Score arrives from Board A, Damage 2 on Boss.”), and the Scene view draws an arrow from it to what it drives, labelled the same way, and one from what it hears. So “a match fires the cannon” is a trigger on the cannon waiting for the board’s Matched, doing Fire; “the beat ends the turn” is one waiting for the clock’s Beat, doing End Turn on the turn order. A Contraptions Wire into an action (its Input set to Spawn, Fire, Damage) does it once each time its signal comes on, with the signal as its amount, as well as holding Power or Show while it’s on. Actions are done where the game is run (offline, or on the host; a player’s own panels and sounds on their machine), and triggers setting each other off stop after a few steps.

Messages go to everyone, unless what sends them says otherwise. Give an entity a Message Scope and the messages it and everything inside it send (a board’s Score, a switch’s On Message, a goal’s Covered) go only to its Target (itself when that’s empty) and everything inside it (To is Children to begin with), or to the target alone (Entity): with two match boards side by side, each with a scope and its own score counter inside it, each counter counts only its own board. Counters, triggers, sound players, panels and scripts’ On outside the scope don’t hear them.

Anything can read anything with no code. Components name what they know as outputs: a match board’s Score, Swaps, Moves Left and Chain, a falling board’s Score, Lines, Level and Game Over, a goal’s Covered and the scene’s Goals Covered out of its Goals, a move history’s Moves, a dungeon’s Floor, a turn order’s Round, Turn (whose it is), Time Left and Left:Enemy (how many of a side’s turn takers are left), a beat clock’s Beat, Bar and Beat In Bar, a faction’s Amount:Gold (any resource after the colon), Units and Buildings, a hotbar’s Selected Item, Selected Count and Blocks:Dirt, an inventory’s Count:Key, a counter’s Count, Reached, Left, Best and New Best, health’s Health, a body’s Speed and Height, a switch’s or wire button’s On, a gate’s Out and a sensor’s Out and Count. Some say what they’re out of: a board’s score out of its Target Score, health out of its Max.

Three things show them: a Text (Track and Output; its Value says how it reads, {0} the output and {1} what it’s out of, with a format after a colon, {0:000} or {0:0.0} m/s, and a value without them shows just the output; a true-or-false output shows On or Off, or with a format is 1 or 0, so {0:'New best!';;''} says something only while it’s on; it’s the one that shows outputs that give a name, such as whose turn it is), a Counter (counting it, and doing something when it reaches a value: see Pickups and scores) and a Bar (filling to it). A Contraptions Wire carries any output that gives a number or true or false (1 or 0) into an input. Without a Track, each reads the entity it’s on or the nearest it’s inside with that output, so a text inside the player shows its speed. Output is picked from a list of what the entity it reads knows, flagged in yellow when it knows nothing called that; MatchBoard.Score names one component’s when two have the same. The Scene view draws an arrow from what’s read to what reads it, labelled with the output. A script component’s own properties join in with [Output] (see Scripting). Reading an output every step makes no garbage, and in a network game each machine reads its own copy of what the host sends.

Flags aren’t only dialogue’s. A trigger’s Set Flag and Clear Flag set and clear them when a message arrives (with the flag’s name as its With), and a Switch, Door, Spawner and Panel can each need one: with Needs Flag PowerOn a lever does nothing, a door stays shut, a spawner waits and a panel won’t open until it’s set; not PowerOn (or !PowerOn) only while it isn’t. So “the gate opens once you’ve talked to the king” is a door needing the flag the king’s dialogue sets, and “the boss comes once the counter reaches ten” is a counter’s Reach Message heard by a trigger that sets the flag a spawner needs. A Show When (Gameplay) shows anything only while its Needs Flag holds: the entity is hidden, with everything inside it, until the flag is set, and hidden again when it’s cleared or a New Game forgets it (a hidden button can’t be clicked and its shortcut does nothing); see Showing things as they’re unlocked. Flags are kept in save data, so they last between runs, but for those named run. (see Dialogue flags).

Give a Pickup an Item (Key) and whoever collects it carries it in an Inventory (one is added to them if they have none, unless they’re on a team whose items they carry: see Items and resources). A Price (5 Coin) makes it a shop’s ware, collected only by someone who can pay. A Door with a Key stays shut to anyone without one, and the first trip through uses it up; a switch with a Key works the same, so a locked block is a solid box with a Button switch that needs a key and Hides itself. A Counter with an Item shows how many the player holds (Keys: {0}). Inventories are saved with the scene, so rewinding gives back the keys picked up since, and you can start a playtest already holding a key by typing Key into the player’s Items. With Save As (Items) an inventory is kept in the save data too, so what the player carries is still there the next time the game runs, and an inventory saved as the same name in the next scene starts with it (a player going from room to room; Game → Clear Save Data forgets it while you test), as a health’s and a counter’s Save As carry theirs (see Carrying inventory, health and counts). Items can be used, too: the inventory’s Item Uses say what each does, one per line (Potion: heal 3, Bomb: spawn Explosion, Scroll: send Teleport; several separated by commas): heal gives back hit points, spawn puts a prefab where the holder stands, and send sends a message with the holder as its data. With Number Keys (on to begin with) the number keys use them, 1 the first item it holds that has a use, 2 the second, and so on, each use taking one out and playing its Use Sound; a potion that only heals is kept while its holder’s health is full. Taking turns, using one is an action and only happens on the holder’s turn. Scripts call Use("Potion"), read Usable and EffectsOf(item), and hear Used.

Give something a Draggable and the player picks it up with the mouse: press on it (its collider, or its sprite if it has none), carry it, and let go. It’s drawn over everything while it’s held, and keeps the spot it was grabbed by. Give a slot, a hole or a place on the table a Drop Target: something dropped on it (by its middle) lands in its middle, sliding there over its Slide Time, and the target lights up in its Hover Tint while something it would take is held over it. A target Accepts the Kinds named (Red Gem, Blue Gem; empty takes anything) up to its Capacity at a time (0 for any number: a bin, a discard pile); anything else dropped on it slides back where it came from. Untick Snap for an area things stay where they’re let go in, and tick Swap on inventory slots so dropping on a full one swaps the two. Off a target, a draggable stays where it’s let go, lands in the middle of a square of its Grid size (1 lines it up with a tilemap’s cells), or with Only On Targets goes back. Stays On Target fixes a jigsaw piece once it’s in place. Draggables play their Pick Up Sound and Drop Sound and send their Pick Up Message and Drop Message; targets send a Drop Message when something lands and a Take Message when it’s taken off, and every target with the same All Full Message sends it once they’re all full: every piece in place, the puzzle solved. What’s on a target is whatever rests with its middle inside it, so things placed on a target in the Scene view start on it. In a network game the host carries things for each player by their own mouse, and two can’t hold the same thing.

For a game played with a controller or keys, give a cursor (or a character) a Grabber. Press its Action (Interact: E, Enter or the gamepad’s Y) and it picks up the draggable under its hand, or else the nearest one whose middle is within its Reach; press again and it puts it down where it’s held, onto a drop target as the mouse would. What a press would pick up lights up in its Highlight. A put-down the mouse would send back (on a full target, one for other kinds, or off targets for something that only goes on them) does nothing instead, so it keeps holding the thing and plays its Refuse Sound; put down on a full target that swaps, it picks up what was there, so a controller can shuffle an inventory around. Tick Hold To Carry to carry only while the button is held. Its Hold Offset is where it holds things: its X is in front of it (the side it faces, turning as it does) and its Y up, so 0, 1 carries a crate over a character’s head and 0.8, 0 in front of it; a cursor keeps 0, 0. Move a cursor with a Top-down Movement (or a Grid Movement, to step from slot to slot), which ignores gravity, so a cursor works in a game that has some. Grabbers send a Pick Up Message and Drop Message with what they moved, and scripts read Holding and InReach, hear PickedUp and Dropped, and call Press(). In a network game each player’s grabber answers to their own controller.

Every template has a pause menu. Both the Platformer and Top-down players carry a sword (X). The Platformer template has a lift up to a ledge where a slime patrols (two swings defeat it) and a lever brings out a bridge with more coins, a spring up to two ledges that crumble under you, a checkpoint flag, a sign to read, and a player with three hearts who comes back at the flag. The Top-down template is a dim dungeon lit by flickering torches and the player’s lantern; in it a bat chases you once it sees you, portals take you across the room, there’s someone to talk to, a key across the room opens a vault, and a crate pushed onto a plate brings out a bonus gem. The Isometric template is a sunny ruined courtyard seen at a slant, on an isometric map: a floor that doesn’t collide and a layer of stone walls, a hedge and low walls along the front that’s solid and sorts each diagonal among the sprites, so the hero walks behind the old shed’s walls and in front of them. Its people stand on the diamonds (their colliders are flat boxes at their feet), gems float over their cells (one in the shed, one behind the hedge, three in the corners), a slime chases you on sight and finds its way round the walls, a crate pushed up into the hedge’s corner presses a plate that brings out a bonus gem, and the gardener talks to you from the diamonds round them. All three templates’ players move with no script and dash with Shift, leaving streaks; the Arcade template’s bullets leave streaks too, and its scripts are the place to see how a game is coded.