Classic RPG is a dialogue system modelled on the dialogue in old-school RPGs. Lines and choices appear in a box at the bottom of the screen, and the text types out letter by letter. The player can speed through lines with a skip button, and your writers can slow the text down, pause it, colour it, and show an item icon next to a line.
Classic RPG is included with Yarn Spinner+ for Godot (GDScript).
Trying the sample
The sample is a small night-time town where you can walk up to a merchant and talk to them. It uses the characters and environment art from the free Yarn Spinner for Godot samples, so your project needs the samples’ samples folder.
Open addons/yarn_spinner_classic_rpg/sample/classic_rpg.tscn and run it with Run Current Scene. Move with WASD or the arrow keys, and press E to talk.
Adding it to your game
- Instance
addons/yarn_spinner_classic_rpg/classic_rpg_dialogue_system.tscnin your scene. - Select its DialogueRunner node, and set its Yarn Project.
- Turn on Auto Start and choose a Start Node, or start the dialogue from your own code.
The dialogue box is laid out for Godot’s default window size of 1152×648. If your project uses a different size, set to canvas_items, so the box scales with the window.
Most of Classic RPG’s settings are on the DialoguePresenter node, a ClassicRPGDialoguePresenter. The Feature Flags group at the bottom of its Inspector turns each part on or off: audio, options, icons, the appearance animation, the action button, the letterbox, skipping, and background styles.
Writing for Classic RPG
Hashtags
Classic RPG looks for these hashtags on your lines:
| Hashtag | What it does |
|---|---|
#end | This is the last line of the conversation. The “next” arrow becomes a square, so the player knows the conversation is about to end. Skipping stops here. |
#noskip | The player can’t skip this line, and any skipping stops here. |
#icon:Name | Shows the icon called Name next to the line. See Icons. |
#center | Centres the line in the box, instead of lining it up on the left. |
#lastline | The next thing is a set of options, so the line stays on screen with them. Yarn Spinner adds this one to the line before every set of options, so you never write it yourself. |
Commands
| Command | What it does |
|---|---|
<<hide_dialogue>> | Closes the box immediately, for example before a cutscene. It opens again, with its appearance animation, when the next line runs. |
<<set_dialogue_style name>> | Changes the box’s background to the style called name. See Box styles. |
Hide the box before you change its style. Otherwise the background changes while the box is on screen, which can look jarring.
Speed, pauses and colour
The text types out at the Presenter’s Characters per Second. Inside a line, [speed] changes it for part of the line, and [pause] stops for a moment:
NPC: I'm speaking [speed=5]slowly...[/speed] [speed=200]and now I'm speaking quickly![/speed]
NPC: It's time for the dramatic reveal... [pause=500 /] classic RPGs are back![speed=N]shows N characters a second.[speed=0]shows its text all at once.[pause=500 /]waits for 500 milliseconds. A decimal, like[pause=0.5 /], is in seconds.
While the player is skipping, [speed] and [pause] are ignored.
The Presenter’s Palette sets which colour markup you can use. The palette that comes with Classic RPG, classic_rpg_palette.tres, has [c0] for red, [c1] for green and [c2] for blue:
NPC: I'm [c0]speaking[/c0] [c1]in[/c1] [c2]technicolour[/c2]!To use your own colours, make a new YarnMarkupPalette resource, add your markers to it, and set it as the Presenter’s Palette. See Markup for how palettes work.
An example
This conversation from the sample uses most of these:
title: NPCVideoTest
---
NPC: Hi! I'm a friendly merchant!
NPC: [speed=0]It's [pause=500/]simple!![/speed] [pause=1000/] [speed=100]I'm a [c0]crook[/c0]![/]
-> Buy a stick
<<hide_dialogue>>
<<set_dialogue_style blue>>
You now own this fantastic [c1]stick[/c1]! This wasn't a great investment. #icon:ItemStick #end
<<hide_dialogue>>
<<set_dialogue_style normal>>
-> Don't buy
NPC: Well, see you later!
===[c0] makes “crook” red.ItemStick icon. #end turns the arrow into a square.Skipping
When the player presses the Presenter’s Skip Action, the text types out at Skip Characters per Second, and each line moves on by itself as soon as it’s finished. The Skip Action is ui_cancel by default, which is Escape on a keyboard, and B or Circle on most controllers.
Skipping carries on until the dialogue reaches a line tagged #end or #noskip, or a set of options.
Options
Options appear in the box, under the line that came before them. There’s room for three or four, depending on how long that line is. Each option is made from option_item.tscn, which you can duplicate and restyle, then set as the Presenter’s Option Item Scene. As the player moves between options, the Presenter plays its Change Option Sound.
To show options with a different Presenter, turn off Use Options.
Icons
To show an icon next to a line, add a texture to the Presenter’s Icons dictionary. Its key is the name you use in #icon:. Names can’t have spaces, or any punctuation other than - and _.
The sample’s Presenter has icons called ItemStick and ItemShield.
Box styles
The Presenter’s Background Styles dictionary holds the textures the box can use as its background. It comes with two:
normal: a see-through black box, with rounded corners and hard edges.blue: a see-through, blurred blue box, with soft edges.
Default Style is the one the box uses when the dialogue starts. To add your own style, add a texture to Background Styles, and switch to it with <<set_dialogue_style>>.
The rest of the screen
- When the dialogue starts, black letterbox bars slide in at the top and bottom of the screen. To change their size or timing, edit the
showanimation onCanvas/Screen/Letterbox/AnimationPlayer. - The box grows onto the screen, overshoots a little, and settles. To change this animation, edit the
appearanimation onCanvas/Screen/DialoguePresenter/Container/AnimationPlayer. - The action button, at the top of the screen, shows what the interact button does: Next Line Label (“Next”), Leave Conversation Label (“Return”), or Select Option Label (“Decide”). Your game can use the same button too. In the sample, it says “Speak” when the player is near someone.
- The Presenter plays a sound when the player moves to the next line (NextLineSound), when a line tagged
#endfinishes typing (EndDialogueSound), and when the player moves on from a line tagged#end(LeaveDialogueSound). The next-line sound doesn’t play while the player is skipping. Each one is anAudioStreamPlayerunder the Presenter, so you can give it a different stream.
The camera moves in the sample aren’t part of Classic RPG. The sample has a script that listens for the Dialogue Runner’s dialogue_started and dialogue_completed signals, and moves the camera closer while the conversation runs.