Basic Concepts
Understand the basics of interactive storytelling
Wichtige Konzepte
Why this matters
π’ Variables & Query DSL
TellsTree uses its own domain-specific language (DSL) to reach the data in your story. With this query syntax you can reach nodes, edges, project information and variables.
π‘ Important: the DSL allows dynamic content, conditional branches and variable dialogues. It is the heart of the interactive features in TellsTree.
π Query Syntax
Grundformat:
- entity β the entity type:
node,edge,self,project - selector β ID oder
self(optional) - field β Das Datenfeld:
content,variables,label,type, etc. - key β array key for nested data (optional)
β Valid queries:
π‘ Explanations:
node[21]β reach the node with id 21selfβ the current node or edge in the contextcontent[name]β the field "name" of the content objectvariables[level]β Variable "level"project.titleβ Projekttitel (ohne Selektor)
π― Available entities
π΅ node
access to story nodes (characters, dialogues, scenes, etc.)
contentβ Content-Daten (Array)variablesβ Gespeicherte Variablenmediaβ Media-URLslabelβ Anzeigenametypeβ Node-Typnode_id/idβ Eindeutige ID
π edge
access to the connections between nodes
conditionβ Bedingungsdaten (Array)typeβ Edge-Typ (flow/contains/link)edge_id/idβ Eindeutige IDfrom_node_idβ Start-Nodeto_node_idβ Ziel-Node
β self
a reference to the current entity in the context (node or edge)
- access to its own data
- Relative Referenzen
- context-dependent queries
π project
access to project metadata
project_id/idβ Projekt-IDtitleβ Projekttiteldescriptionβ Beschreibungis_publicβ public?
π¨ Template Resolution
Queries can be embedded in templates with double curly braces.
Syntax:
β Wird zu: Hello, Alice! (when node 15 has name="Alice")
π Verschachtelte Queries:
TellsTree resolves nested queries. The innermost expressions in parentheses () are resolved first.
1. (self.data.speakerId) β 01HQRST...
2. node[id=01HQRST...].data.name β Alice
Examples:
β Your level: 5
β Hello, John
Use cases:
- β Dynamische Dialog-Texte
- β Variable Edge-Labels
- β Bedingte Anzeige-Texte
- β Player-spezifische Inhalte
- β context-dependent UI
βοΈ Bedingungen (Conditions)
Queries can be used in conditions to show edges or UI elements conditionally.
Struktur:
{
"query": "self.variables[level]",
"operator": ">=",
"value": 5
}
β the condition holds when level β₯ 5
Available operators:
== / equals=== / strict_equals!= / not_equals> / greater_than>= / greater_or_equal< / less_than<= / less_or_equalcontainsinExample conditions:
π― Verwendung in Edges:
Flow edges can carry conditions. Only edges whose condition holds are active in the gameplay. This allows branching narratives based on the player's decisions and state.
π Sicherheit & Permissions
Automatische Permission-Checks:
- β all queries are validated against project access
- β only nodes and edges in the current project can be reached
- β user permissions are checked automatically
- β public projects are readable for everyone
- β private projects only for the owner and the members
π‘ Note: invalid queries (for example missing permissions, ids that do not exist)
return null and are logged. The system is designed to fail safe.
π Best Practices
β Do:
- β’ use
selffor relative references - β’ use speaking variable names
- β’ test conditions before production
- β’ use templates for dynamic content
- β’ Halte Queries einfach und lesbar
β Don't:
- β’ Vermeide zu tief verschachtelte Queries
- β’ no queries on ids that do not exist
- β’ no circular references
- β’ no sensitive data in variables
- β’ no more than 10 levels of nesting
π Query DSL (Domain-Specific Language)
TellsTree uses its own domain-specific language to reach the data in your projects. The DSL allows dynamic content, conditional branches and interactive dialogues.
π‘ Neu in Version 2.0: Die DSL verwendet jetzt Dot-Notation statt Bracket-Notation for cleaner, more readable expressions.
π Syntax overview
Dot-Notation (Neu):
Bracket-Notation (Alt, veraltet):
β Valid expressions:
π‘ Bedeutung:
selfβ Aktueller Node oder Edgeprojectβ Aktuelles Projektnode[id=...]β Spezifischer Node (ULID)$variableβ Variable aus Kontext(...)β Gruppierter Ausdruck.field.nestedβ Verschachtelte Felder
π― Referenztypen
πΉ Self-Referenz
Reaches the node or edge that evaluates the expression.
self.variables.level
self.type
πΉ Project-Referenz
Reaches the current project.
project.variables.questComplete
project.owner_id
πΉ Entity-Referenz (Node/Edge)
Reaches one specific node or edge by its ULID.
edge[id=01HQRST0123456789ABCDEFG10].data.distance
node[id=$targetNodeId].variables.health
$variableName
πΉ Variable-Referenz
Reaches variables from the context.
$questComplete
$targetNodeId
π Feld-Zugriff
After the reference you can reach nested fields with dot notation:
Verschachtelte Pfade:
β οΈ Important: when a field does not exist, the DSL in lenient mode
null. In strict mode an exception is thrown.
β οΈ Fehlerbehandlung
Lenient-Modus (Standard):
Missing fields or entities return null; no errors are thrown.
Strict-Modus:
Errors are thrown as exceptions. Useful for debugging.
π Examples
Example 1: Character information
Returns the name of the character from the current node.
Example 2: Quest progress
Returns the number of finished quests from the project variables.
Example 3: A referenced NPC
Reaches the name of an NPC whose id is kept in the variable $mentorId.
Example 4: Nested data
Reaches the current health from nested variables.
β¨ Best Practices
- β Use self to reach the current node or edge
- β Use project for the global project data
- β Use variables ($varName) for dynamic id references
- β Vermeiden Sie tiefe Verschachtelung (max. 5-7 Ebenen)
- β Do not use the old bracket notation (outdated)
- β Do not use numeric ids (only ULIDs are supported)
π― Conditions System
The conditions system allows conditional logic in TellsTree. With predicates and conjunctions you can build complex conditions that decide whether an edge is visible or which actions are available.
π‘ Important: conditions use the DSL syntax to reach data and support AND/OR joins of any depth.
ποΈ Struktur
Eine Condition besteht aus zwei Haupttypen:
πΉ Predicate (Vergleich)
Ein einzelner Vergleich zwischen zwei Werten.
πΉ Conjunction
Joins several conditions with AND or OR.
βοΈ Operatoren
== (Gleich)
Strenger Gleichheitsvergleich (keine Typ-Konvertierung).
true when both values are identical.
!= (Ungleich)
Strenger Ungleichheitsvergleich.
true when the values differ.
in (Enthalten in)
Checks whether an element is contained in an array or a string.
contains
Checks whether a container holds an element (symmetric to "in").
π Conjunctions
AND (all must hold)
Returns true when all conditions hold.
β Both conditions must be true.
OR (at least one must hold)
Returns true when at least one condition holds.
β At least one condition must be true.
Verschachtelte Conjunctions
Conjunctions can be nested to any depth.
β Entspricht: character AND (level >= 10 OR hasKey)
π Examples
Example 1: A simple level check
Checks whether the player has reached at least level 5.
Example 2: A class check
Checks whether the character is a mage or a sorcerer.
Example 3: Quest gating
Checks several conditions for quest access: level, previous quest and item.
Example 4: Cross-node reference
Checks the trust level of another NPC (a mentor).
π Edge Conditions
Edges can carry conditions that decide whether they are visible or clickable.
Edge-Struktur:
π‘ Important: in edge conditions self refers to the
source node, not to the edge itself.
β¨ Best Practices
- β Use explicit conjunctions for clarity
- β Halten Sie Conditions flach (max. 3-4 Ebenen Tiefe)
- β Use variables for dynamic values
- β Test conditions in strict mode while building
- β Vermeiden Sie Typ-Vermischung (Zahlen vs. Strings)
- β Avoid circular references
- β Use no more than 10 conditions per conjunction
π Template System
The template system allows dynamic content in TellsTree. With the
{{...}} syntax you can embed DSL expressions in texts,
which are resolved at run time.
π‘ Important: templates use the same DSL syntax as conditions,
aber mit spezieller Template-Markierung {{...}}.
π€ Template-Syntax
Grundformat:
Alles zwischen {{...}} is treated as a DSL expression and resolved at run time.
β Valid templates:
π‘ Ergebnisse:
π’ Several expressions
You can use any number of template expressions in one text:
Template:
Ergebnis:
π¨ Datentypen
Template expressions are converted to strings automatically:
Strings
Zahlen
Booleans
Arrays
Null/Undefined
π Verschachtelte Templates
Templates can resolve other templates (at most 5 levels deep):
Example:
β οΈ Important: circular template references are detected and lead to an error, or return the template unchanged (depending on the mode).
π― Use cases
1. Dialog-Text
Personalised NPC dialogues with the player's name and state:
2. Quest-Beschreibungen
Dynamic quest texts with goals and items:
3. Status-Anzeigen
HUD-Elemente mit aktuellen Werten:
4. Bedingte Texte
Texts that are shown based on conditions:
β οΈ Fehlerbehandlung
Lenient-Modus (Standard):
Failed expressions are replaced by empty strings:
Strict-Modus:
Errors are thrown as exceptions (useful for debugging):
π Complete examples
NPC-Dialog
Quest-Log-Eintrag
β¨ Best Practices
- β Use short, readable expressions in templates
- β Keep complex values in variables
- β Use fallback values for optional fields
- β Test templates in strict mode while building
- β Vermeiden Sie tiefe Verschachtelung (> 3 Ebenen)
- β Avoid complex expressions right in templates
- β Use no arrays right in texts (format them first)
π Edge Types
In TellsTree unterscheiden wir drei grundlegende Edge-Typen, die jeweils unterschiedliche carry meaning of their own and differ in how they are shown and checked.
π‘ Important: the right choice of edge type decides
Validierung und Darstellung Ihrer interaktiven Geschichten. Nur flow-Edges
can be tested and form the logical flow.
π¦ 1οΈβ£ contains β structural belonging
Beschreibt hierarchische Beziehungen und Besitz. This edge type says that one element is part of another.
Eigenschaften:
- Beschreibt Besitz, Teilmenge, Einbettung
- No element of time
- No direction in the sense of a flow
- No conditions possible
- Nicht test-relevant
Semantische Aliase:
Examples:
Chapter
β
Scene
Scene
β
Story-Segment
Dialog
β
Dialog-Entry
Inventory
β
Item
Character
β
Trait
Stage
β
Gameplay-Segment
All these relations mean: "A belongs to B"
β‘οΈ UI-Darstellung:
- β Kein Pfeil
- β Sidelane / Grouping / Umrandung
- β Rein organisatorisch
π 2οΈβ£ flow β Gerichtete, bedingte Abfolge
This is the only edge type that is temporal, testable and logically relevant. Flow edges define the actual flow of your story.
Eigenschaften:
- Immer gerichtet
- Optional: Bedingungen (conditions)
- Optional: Effekte / Events
- Relevant for validation
- Kann "offene Enden" erzeugen
Semantische Varianten:
β Kritische Regel:
All flow connections must run from start to end. Only flow edges form graphs that can be tested.
Example flow:
Start
β
Scene 1
Scene 1
β
Choice A
Scene 1
β
Choice B
Choice A
β
End
β‘οΈ UI-Darstellung:
- β Gerichteter Pfeil
- β Bedingungen anzeigen
- β Highlighting bei Validierung
- β "Offene Enden" rot markieren
π 3οΈβ£ link β Lose, nicht-sequenzielle Verbindung
An edge type many systems do not keep apart. Links are purely referential and carry no logical or temporal meaning.
Eigenschaften:
- No element of time
- No order
- No validation logic
- Rein semantisch / referenziell
- Optional ein-/ausblendbar
Semantische Varianten:
Examples:
Character A
β―β
Character B
mentions (in dialogue)
Location A
β―β
Location B
connects_to (map reference)
Scene 5
β―β
Scene 12
references (callback)
β οΈ Wichtig:
Link edges are never relevant for tests. They serve only documentation and semantic connection, not the logical flow.
β‘οΈ UI-Darstellung:
- β Gestrichelte Linie oder Pfeil
- β Label / Beschreibung anzeigen
- β Optional ein-/ausblendbar
- β Niemals in Validierung einbeziehen
π Vergleichstabelle
| Eigenschaft | contains | flow | link |
|---|---|---|---|
| Zeitlich | β | β | β |
| Gerichtet | β | β | β (optional) |
| Conditions possible | β | β | β |
| Testrelevant | β | β | β |
| UI-Darstellung | Grouping | Pfeil β | Gestrichelt β―β |
| Validierung | Organisatorisch | Complete | Keine |
π¦ Nodes
Coming soon...
πΈοΈ Graph Structure
Coming soon...