godot_yarn_spinner icon indicating copy to clipboard operation
godot_yarn_spinner copied to clipboard

Godot plugin to use Yarn Spinner stories

Godot Yarn Spinner

A plugin for Godot to use stories made with Yarn Spinner. The plugin parses Yarn code into GDScript files to let the Godot runtime handle the flow of execution in the story.

Note

The plugin is not 100% compatible with Yarn as of now. The current features available are:

  1. Dialogue Statements
  2. Jump Statements
  3. Options
  4. Shortcut Options
  5. Commands
  6. Variable interpolation in dialogue
  7. if, elif, else blocks
  8. Expressions
  9. Conditionals on Options and Shortcut Options

Missing features:

  1. Format functions
  2. Localization tags
  3. Editing the Yarn code within Godot's editor
  4. Headers, Tags accessible from the script

Non-standard features:

  1. Conditional expressions must have their bodies indented

How to use

Your story file must have an extension of .yarn. Within Godot, once the plugin is activated, use the Yarn file in any location where a GDScript file is expected (autoload, singleton, node script, etc.)

The script generated by this plugin has three signals: command, dialogue, options, each for their respective events in the story. It also contains a function called step_through_story which can be used to follow a story-line step-by-step.

On each of the above events, the script emits the signal and yields. To continue the story, call step_through_story (optionally with a value representing an option choice from the user)

Each node in the Yarn file is parsed into a function with the name set as the node title. By default, the starting node is assumed to be called "Start" to match the Yarn Editor. To set the current node, call set_current_yarn_thread with the node name