rmp::Dialogue
A conversation: a compiled Yarn script, where it is in it, and what it remembers. It draws nothing — the presenters of rmp/ui.h do, or the game. Moved, never copied.
Dialogue
No script: loaded() is false
loaded, errors, has_node
Whether a script is loaded and compiled; when not, errors() says why, a line each, as file:line:column: what is wrong.
start, stop, running, node
Run from a node's first line. False when there is no such node.
running: Started, not yet finished
node: The node it is in, or empty
has_line, line, has_options, options, has_command, command
What it is waiting for: a line to be read, a choice, or a command the game did not handle. Nothing of the three when it is not running.
line: Empty when there is none
command: Its text, {expressions} filled
advance
On, past the line or the command.
choose
The option chosen, by its place in options(). When none is available, any number goes on past the options.
on_command
<<name arg arg>> calls handler, and the dialogue goes on by itself — or waits, when the handler calls wait() or wait_until(). A command nobody handles waits in has_command().
Typed: each word after the name arrives as the parameter asks, and a script that gives the wrong number of words, or a word that is not a number where one goes, is a mistake said once, the command not run:
talk.on_command("walk", [&](std::string who, float speed) { ... });
talk.on_command("shake", [&] { camera.shake(); });Or every word as written: [&](std::span<const std::string> words) { ... }.
on_function
name(...) in an expression. Typed: the parameters say what it takes and the result what it gives, and a call with the wrong number or kind of arguments is a mistake said once, never a call:
talk.on_function("has_item", [&](std::string item) -> bool { ... });Or untyped: [&](rmp::DialogueValue &out, std::span<const rmp::DialogueValue> args). Write the result type (-> bool): rmp yarn ysls reads it for the editor.
wait, wait_until
From inside a command's handler: the dialogue waits after the command, for seconds, or until done() is true (asked once a frame, from waiting()). <<wait 2>> waits by itself, when the game has no "wait".
talk.on_command("walk", [&](std::string where) {
mika.walk_to(where);
talk.wait_until([&] { return mika.arrived(); });
});waiting
Whether a command holds the dialogue: no line, no options, until its wait is over. Asking is what moves it on: once a frame, the presenters do it, or the game's own loop.
variable, set_variable
$variables: what the script set, and what the game sets for it.
bind, visits
A $variable that IS one of the game's: the script reads it and writes it, and nothing is copied. The script declares it, with its type (<<declare $gold = 0>>); a binding of another type, or of a variable the script does not declare, is a mistake said once. save() leaves bound variables out: they are the game's to save. The variable must outlive the dialogue.
talk.bind("$gold", player.gold);visits: Visited_count()
save, load
Everything the conversation remembers — variables, visits, what was seen once — into an rmp::Value for rmp::save, and back.
set_saliency
How line groups and node groups choose; LEAST_SEEN unless set.
Dialogue
The script's own: for the loaders below.