Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(dialogue-systems): runnable Ink, Yarn and runner examples; Yarn Spinner 3 presenters and Ink localization facts

Kiro Crew8228f13ec62f
diff --git a/skills/disciplines/dialogue-systems/SKILL.md b/skills/disciplines/dialogue-systems/SKILL.md
index 04066b2..9518a07 100644
--- a/skills/disciplines/dialogue-systems/SKILL.md
+++ b/skills/disciplines/dialogue-systems/SKILL.md
@@ -61,13 +61,14 @@ across sessions, use `save-systems`. For data-as-resources in Godot/Unity, see
"guard_intro": {
"speaker": "Guard", "line": "DLG_GUARD_001",
"choices": [
- { "text": "DLG_OPT_BRIBE", "to": "bribe", "if": "gold >= 50" },
+ { "text": "DLG_OPT_BRIBE", "to": "bribe", "if": "gold >= 50",
+ "set": { "gold": "gold - 50" } },
{ "text": "DLG_OPT_LEAVE", "to": "end" }
]
},
"bribe": {
"speaker": "Guard", "line": "DLG_GUARD_BRIBED",
- "set": { "gate_open": true, "gold": "gold - 50" },
+ "set": { "gate_open": true },
"next": "end"
},
"end": { "end": true }
@@ -76,31 +77,35 @@ across sessions, use `save-systems`. For data-as-resources in Godot/Unity, see
```
`line`/`text` are **string-table IDs** (localization), not literal text. `if`
-gates a choice; `set` mutates the variable store. The full interpreter that walks
-this graph is in `references/runner.md`.
+gates a choice; `set` mutates the variable store. The gold cost sits on the
+*choice*, so it is paid once per pick even if the `bribe` node is revisited; the
+idempotent `gate_open` write can live on the node. A string `set` value is an
+expression, so a literal string needs inner quotes: `"mood": "'angry'"`. The full
+interpreter that walks this graph is in `references/runner.md`.
### 2. Runner step (a state machine over the graph)
```gdscript
-# The runner holds the current node and a variable store; the UI calls advance().
-func present(node):
- if node.has("line"):
- ui.show_line(node.speaker, localize(node.line))
- if node.has("choices"):
- var shown = node.choices.filter(func(c): return eval_cond(c.get("if", "")))
+# Godot 4.7. The runner holds the current node and a variable store. Every line
+# waits for the player: the UI calls choose() or the continue callback.
+func goto(id: String) -> void:
+ current = graph.nodes[id]
+ apply_set(current.get("set", {}))
+ if current.get("end", false):
+ ui.close()
+ return
+ if current.has("line"):
+ ui.show_line(current.get("speaker", ""), localize(current.line))
+ if current.has("choices"):
+ var shown = current.choices.filter(func(c): return eval_cond(c.get("if", "")))
ui.show_choices(shown) # only choices whose condition passes
+ elif current.has("next"):
+ var next_id: String = current.next
+ ui.show_continue(func(): goto(next_id)) # advance when the player continues
-func choose(choice): # called when the player clicks a choice
- apply_set(choice.get("set", {})) # write variables
+func choose(choice: Dictionary) -> void: # called when the player picks a choice
+ apply_set(choice.get("set", {})) # write on the transition (revisit-safe)
goto(choice.to)
-
-func goto(id):
- current = graph.nodes[id]
- apply_set(current.get("set", {}))
- if current.get("end", false): ui.close(); return
- present(current)
- if current.has("next") and not current.has("choices"):
- goto(current.next) # auto-advance linear nodes
```
### 3. Ink — branching with knots, choices, and variables (inkle)
@@ -109,6 +114,7 @@ func goto(id):
// Ink: '*' = once-only choice, '+' = sticky. [bracketed] text shows only in the
// choice, not the printed result. '->' diverts; '-> END' stops the flow.
VAR gold = 60
+-> guard_intro // the story starts at the top: divert into a knot
=== guard_intro ===
The guard blocks the gate.
@@ -142,7 +148,8 @@ Yarn lines may start with `Speaker:`; options use `->`; `<<set>>`/`<<declare>>`
manage `$variables`; `<<if>>` gates an option; `<<jump NodeName>>` moves between
nodes. Interpolate values in text with `{$gold}`. Declare every variable before first
use: an undeclared one still compiles (Yarn infers its type and a zero/false/empty
-start value), but that hides typos. These constructs are unchanged from Yarn Spinner 2.x.
+start value) with only a warning, which hides typos. These constructs are unchanged from
+Yarn Spinner 2.x.
## Pitfalls
diff --git a/skills/disciplines/dialogue-systems/references/ink-and-yarn.md b/skills/disciplines/dialogue-systems/references/ink-and-yarn.md
index 140777d..4c0d860 100644
--- a/skills/disciplines/dialogue-systems/references/ink-and-yarn.md
+++ b/skills/disciplines/dialogue-systems/references/ink-and-yarn.md
@@ -25,19 +25,20 @@ consult the official docs for the full language.
```ink
INCLUDE characters.ink // split content across files (top of file)
-VAR met_guard = false // global variable
+VAR gold = 60 // global variables
+VAR met_guard = false
CONST GATE_COST = 50
-> tavern // content outside a knot runs first; divert in
=== tavern ===
The tavern is warm and loud.
-* [Talk to the guard] -> guard
++ [Talk to the guard] -> guard // sticky: still offered when you come back
* [Leave] -> END
=== guard ===
+{ met_guard: "You again." | "Who are you?" } // conditional text: read the flag first
~ met_guard = true // '~' marks a logic line (assignment / call)
-{ met_guard: "You again." | "Who are you?" } // conditional text: seen-before?
+ {gold >= GATE_COST} [Pay {GATE_COST} gold] // sticky choice, gated, interpolated
~ gold = gold - GATE_COST
-> END
@@ -47,7 +48,7 @@ The tavern is warm and loud.
Useful Ink behaviors:
- **Square brackets in a choice** split what the player sees from what prints:
- `* "Yes[."]," I said.` shows `Yes.` as the option but prints `Yes," I said.`
+ `* "Yes[."]," I said.` offers the option `"Yes."` and prints `"Yes," I said.`
- **Gathers** (`-`) rejoin branches without naming a knot — the core of "weave".
- **Read counts**: any knot/stitch name used in a condition is the number of
times it has been visited (`{seen_clue > 2}`), so flags are often free.
@@ -72,12 +73,12 @@ The tavern is warm and loud.
title: Guard
---
-<<set $met_guard to true>>
<<if $met_guard>>
Guard: You again.
<<else>>
Guard: Who are you?
<<endif>>
+<<set $met_guard to true>>
-> Pay 50 gold <<if $gold >= 50>>
<<set $gold = $gold - 50>>
Guard: ...go on through. You have {$gold} left.
@@ -96,17 +97,29 @@ Useful Yarn behaviors:
e.g. `<<playSound door_open>>` calls a registered command handler.
- **Functions** (`visited("Node")`, custom registered functions) return values
usable in `<<if>>` and `{ }` interpolation.
+- **Yarn Spinner 3 additions** (need Yarn language version 3; an older project
+ fails with "requires version 3 or later"): `<<once>>` … `<<endonce>>` runs a block only
+ the first time; `<<detour Node>>` visits a node and returns, where `<<jump>>`
+ never comes back; several nodes sharing one `title:` with `when:` headers form
+ a node group, and the runner picks one whose condition passes (for barks and
+ storylets).
## Integration notes
-- **Ink**: compile `.ink` to JSON, then step the runtime: it yields lines and
- choice lists; you call `Continue()` / `ChooseChoiceIndex()`. Bindings exist for
- Unity (official), Godot (community), and web (inkjs).
-- **Yarn Spinner**: a `DialogueRunner` steps `.yarn` nodes, raising line, options,
- and command events your views handle. First-class Unity support; Godot and
- other runtimes exist.
-- **Localization**: both support extracting line IDs/tags to string tables. Tag
- lines and ship per-locale tables rather than translating the script in place.
+- **Ink** (1.2.x): compile `.ink` to JSON, then step the runtime: loop
+ `Continue()` while `canContinue`, show `currentChoices`, call
+ `ChooseChoiceIndex(i)`, and then `Continue()` again; the chosen branch does not
+ print until you do. Integrations: Unity (official, inkle), web (inkjs), Godot
+ (community C# and GDScript ports).
+- **Yarn Spinner** (3.x): a `DialogueRunner` steps `.yarn` nodes and hands lines
+ and options to **Dialogue Presenters** (`DialoguePresenterBase` subclasses; 3.0
+ replaced 2.x Dialogue Views), while commands go to registered handlers. Official
+ integrations exist for Unity, Godot (C# and GDScript editions) and Unreal.
+- **Localization**: Yarn Spinner tags every line with a `#line:` ID and exports
+ string tables per locale. Ink has no built-in line-ID localization: either
+ translate whole `.ink` files per locale, or tag lines (`#id:guard_01`) and look the
+ text up in your own tables by tag. Either way, ship per-locale data rather than
+ editing the script in place.
- **Variable bridging**: expose game state to the script (gold, flags, quest
stage) via variable storage / external functions so dialogue reacts to play,
and persist that state through `save-systems`.
diff --git a/skills/disciplines/dialogue-systems/references/runner.md b/skills/disciplines/dialogue-systems/references/runner.md
index fe9bdd1..16e14e6 100644
--- a/skills/disciplines/dialogue-systems/references/runner.md
+++ b/skills/disciplines/dialogue-systems/references/runner.md
@@ -49,10 +49,12 @@ def evaluate(expr, vars):
def ev(node):
if isinstance(node, ast.Expression): return ev(node.body)
if isinstance(node, ast.Constant): return node.value
- if isinstance(node, ast.Name): return vars.get(node.id)
+ if isinstance(node, ast.Name): return vars[node.id] # KeyError names a typo
if isinstance(node, ast.BoolOp): return _BOOL[type(node.op)](ev(v) for v in node.values)
if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not):
return not ev(node.operand)
+ if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.USub):
+ return -ev(node.operand) # negative literals: "rep > -5"
if isinstance(node, ast.BinOp): return _BIN[type(node.op)](ev(node.left), ev(node.right))
if isinstance(node, ast.Compare):
left = ev(node.left); res = True
@@ -64,8 +66,12 @@ def evaluate(expr, vars):
```
This whitelists only names, literals, arithmetic, comparison, and boolean ops —
-it cannot call functions or touch the host environment. (Engines without a safe
-parser should ship a hand-written tokenizer instead of exposing a real `eval`.)
+it cannot call functions or touch the host environment. The syntax is Python's, so
+booleans are `True`/`False`, logic is `and`/`or`/`not`, and a string literal needs
+inner quotes (`"mood == 'angry'"`). An unknown name raises `KeyError` instead of
+quietly comparing `None`, which would itself raise `TypeError` on `<`/`>`. (Engines
+without a safe parser should ship a hand-written tokenizer instead of exposing a real
+`eval`.)
## The runner state machine