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.
The plugin is not 100% compatible with Yarn as of now. The current features available are:
- Dialogue Statements
- Jump Statements
- Options
- Shortcut Options
- Commands
- Variable interpolation in dialogue
- if, elif, else blocks
- Expressions
- Conditionals on Options and Shortcut Options
Missing features:
- Format functions
- Localization tags
- Editing the Yarn code within Godot's editor
- Headers, Tags accessible from the script
Non-standard features:
- Conditional expressions must have their bodies indented
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