Yarn Spinner 3 is now available!
Buy Now
LogoLogo
HomepageDiscordItchPatreonAsset Store
Yarn Spinner 3.0
Yarn Spinner 3.0
  • ⭐Start Here
    • Yarn Spinner 3
  • Beginner's Guide
  • About Yarn Spinner
  • Crediting Yarn Spinner
  • FAQ
  • Writing Yarn Scripts
    • ⭐First Steps with Scripting
    • Yarn Spinner Editor
      • Writing Yarn in VS Code
      • Previewing Your Dialogue
      • Writing Together
    • Scripting Fundamentals
      • Nodes and Lines
      • Options
      • Jump Command
      • Detour Command
      • Variables
      • Flow Control
      • Once
      • Smart Variables
      • Enums
      • Commands
      • Functions
      • Line Groups
    • Advanced Scripting
      • Node Groups
      • Storylets and Saliency Primer
      • Saliency
      • Tags and Metadata
      • Markup
      • Shadow Lines
  • Yarn Spinner for Unity
    • ⭐First Steps with Unity
    • Installation for Unity
      • Unity Quick Start
    • Yarn Spinner in Unity Scenes
      • Unity Projects + Yarn Spinner
    • Your First Yarn Spinner Game
    • Commands and Functions
    • Localisation and Assets
      • In-built Localisation
      • Unity Localisation
    • Samples
      • Welcome
      • Feature Tour
      • Theming Default Presenters
      • Create a Phone Chat View
      • Make Options Timeout
      • Voice Over and Localisation
      • Background Chatter
      • Inline Events
      • Replacement Markup
      • Storylets and Saliency
        • Basics Storylets and Saliency
        • Advanced Saliency
        • Custom Saliency Strategies
    • Unity Add-Ons
      • Speech Bubbles
        • Installing Speech Bubbles
        • Using Speech Bubbles
        • Speech Bubble Examples
      • Dialogue Wheel
        • Installing Dialogue Wheel
        • Using Six-Segment Wheel
        • Using Auto-Layout Wheel
        • Dialogue Wheel Examples
  • Components
    • Dialogue Runners and Systems
    • Dialogue Presenters
      • Line Presenter
      • Options Presenter
      • Line Advancer
      • Custom Dialogue Presenters
    • Variable Storage
      • In-Memory Variable Storage
      • Variable Storage
      • Custom Variable Storage Components
    • Line Provider
      • Built-in Localised Line Provider
      • Unity Localised Line Provider
    • Asynchronous Programming
  • Changelog
    • Upgrading from Yarn Spinner 2
  • Yarn Spinner for Other Engines
    • Godot
      • Overview
      • 📦Installation for Godot
      • 📥Importing Yarn Files
        • Yarn Projects
        • Yarn Scripts
      • 🧱Components
        • Dialogue Runner
        • Dialogue Views
          • Line View
          • Options List View
          • Option View
          • Creating Custom Dialogue Views
        • Variable Storage
          • In-Memory Variable Storage
          • Custom Variable Storage Components
        • Line Provider
          • Text Line Provider
        • Markup Palette
      • 🤖Commands and Functions
      • 🗺️Localization
      • Advanced Guides
        • Implementing Custom Variable Storage
    • Unreal
      • 🧑🏼‍🏫Unreal Beta Quickstart
    • Bevy
      • ⚡Bevy Quick Start
      • 📥Compiling Yarn Files into Yarn Projects
      • 🧱Components
        • Dialogue Runner and a High Level Overview
        • Dialogue Views
        • Variable Storage
        • Assets
      • 🤖Custom Commands and Functions
        • Commands
        • Functions
      • 🗺️Localisations
      • 💡Frequently Asked Questions / "How Do I...?"
      • 🎁Bevy Samples
  • API
    • C#
      • Yarn.Utility Namespace
        • CRC32
          • GetChecksum(byte[])
          • GetChecksum(string)
          • GetChecksumString(string)
      • Yarn Namespace
        • Command
          • Text
        • CommandHandler
        • ConstantTypeProperty
          • Description
          • Type
          • Value
        • Dialogue
          • DefaultStartNodeName
          • Dialogue(Yarn.IVariableStorage)
          • Continue()
          • GetHeaders(string)
          • GetHeaderValue(string,string)
          • GetSaliencyOptionsForNodeGroup(string)
          • GetStringIDForNode(string)
          • GetTagsForNode(string)
          • HasSalientContent(string)
          • IsNodeGroup(string)
          • NodeExists(string)
          • SetNode(string)
          • SetProgram(Program)
          • SetSelectedOption(int)
          • Stop()
          • TryGetSmartVariable(string,T)
          • UnloadAll()
          • CommandHandler
          • ContentSaliencyStrategy
          • CurrentNode
          • DialogueCompleteHandler
          • IsActive
          • Library
          • LineHandler
          • LogDebugMessage
          • LogErrorMessage
          • NodeCompleteHandler
          • NodeNames
          • NodeStartHandler
          • OptionsHandler
          • PrepareForLinesHandler
          • VariableStorage
        • DialogueCompleteHandler
        • DialogueException
        • EnumBase
          • EnumBase()
          • Description
          • Name
          • Parent
        • EnumType
          • EnumType(string,string,TypeBase)
          • Description
          • EnumCases
          • Name
          • Parent
          • RawType
        • FunctionType
          • FunctionType(IType,IType[])
          • Equals(IType)
          • GetParameterAt(int)
          • ToString()
          • Description
          • Name
          • Parameters
          • Parent
          • ReturnType
          • TypeMembers
          • VariadicParameterType
        • Header
          • KeyFieldNumber
          • ValueFieldNumber
          • Header()
          • Header(Header)
          • CalculateSize()
          • Clone()
          • Equals(object)
          • Equals(Header)
          • GetHashCode()
          • MergeFrom(pb::CodedInputStream)
          • MergeFrom(Header)
          • ToString()
          • WriteTo(pb::CodedOutputStream)
          • Descriptor
          • Key
          • Parser
          • Value
        • IMarkupParser
          • ParseMarkup(string,string)
        • ISmartVariableEvaluator
          • TryGetSmartVariable(string,T)
        • IType
          • Description
          • Name
          • Parent
          • TypeMembers
        • ITypeMember
          • Type
        • IVariableAccess
          • GetVariableKind(string)
          • TryGetValue(string,T?)
          • Program
          • SmartVariableEvaluator
        • IVariableStorage
          • Clear()
          • SetValue(string,bool)
          • SetValue(string,float)
          • SetValue(string,string)
        • IYarnValue
          • ConvertTo()
        • Library
          • DeregisterFunction(string)
          • FunctionExists(string)
          • GenerateUniqueVisitedVariableForNode(string)
          • GetFunction(string)
          • ImportLibrary(Library)
          • RegisterFunction(string,Delegate)
          • RegisterFunction(string,Func<TResult>)
          • RegisterFunction(string,Func<T1, TResult>)
          • RegisterFunction(string,Func<T1, T2, TResult>)
          • RegisterFunction(string,Func<T1, T2, T3, TResult>)
          • RegisterFunction(string,Func<T1, T2, T3, T4, TResult>)
          • RegisterFunction(string,Func<T1, T2, T3, T4, T5, TResult>)
        • Line
          • Line(string,string[])
          • ID
          • Substitutions
        • LineHandler
        • Logger
        • MemoryVariableStore
          • Clear()
          • GetVariableKind(string)
          • SetValue(string,bool)
          • SetValue(string,float)
          • SetValue(string,string)
          • TryGetValue(string,T?)
          • Program
          • SmartVariableEvaluator
        • Node
          • NodeGroupHeader
          • ToString()
          • ContentSaliencyConditionComplexityScore
          • ContentSaliencyConditionVariables
          • Headers
          • Instructions
          • IsNodeGroupHub
          • Name
          • NodeGroup
          • Tags
          • TrackingVariableName
        • NodeCompleteHandler
        • NodeStartHandler
        • OptionSet
          • Options
          • Option
            • ID
            • IsAvailable
            • Line
        • OptionsHandler
        • PrepareForLinesHandler
        • Program
          • GetVariableKind(string)
          • LineIDsForNode(string)
          • ToString()
          • TryGetInitialValue(string,T)
          • InitialValues
          • Name
          • Nodes
        • TypeBase
          • Equals(object)
          • Equals(TypeBase)
          • GetHashCode()
          • IsAncestorOf(TypeBase)
          • IsConvertibleTo(TypeBase)
          • ToString()
          • ConvertibleToTypes
          • Description
          • Methods
          • Name
          • Parent
          • TypeMembers
        • Types
          • Any
          • Boolean
          • Number
          • String
          • TypeMappings
        • VariableKind
          • Smart
          • Stored
          • Unknown
      • Yarn.Saliency Namespace
        • BestLeastRecentlyViewedSaliencyStrategy
          • BestLeastRecentlyViewedSaliencyStrategy(IVariableStorage)
          • ContentWasSelected(ContentSaliencyOption)
          • QueryBestContent(IEnumerable<ContentSaliencyOption>)
        • BestSaliencyStrategy
          • ContentWasSelected(ContentSaliencyOption)
          • QueryBestContent(IEnumerable<ContentSaliencyOption>)
        • ContentSaliencyContentType
          • Line
          • Node
        • ContentSaliencyOption
          • ContentSaliencyOption(string)
          • ComplexityScore
          • ContentID
          • ContentType
          • FailingConditionValueCount
          • PassingConditionValueCount
          • ViewCountKey
        • EnumerableRandomExtension
          • RandomElement(IEnumerable<T>)
        • FirstSaliencyStrategy
          • ContentWasSelected(ContentSaliencyOption)
          • QueryBestContent(IEnumerable<ContentSaliencyOption>)
        • IContentSaliencyStrategy
          • ContentWasSelected(ContentSaliencyOption)
          • QueryBestContent(IEnumerable<ContentSaliencyOption>)
        • RandomBestLeastRecentlyViewedSaliencyStrategy
          • RandomBestLeastRecentlyViewedSaliencyStrategy(IVariableStorage)
          • ContentWasSelected(ContentSaliencyOption)
          • QueryBestContent(IEnumerable<ContentSaliencyOption>)
      • Yarn.Markup Namespace
        • BuiltInMarkupReplacer
          • ProcessReplacementMarker(MarkupAttribute,StringBuilder,List<MarkupAttribute>,string)
        • IAttributeMarkerProcessor
          • ProcessReplacementMarker(MarkupAttribute,System.Text.StringBuilder,List<MarkupAttribute>,string)
        • LineParser
          • CharacterAttribute
          • CharacterAttributeNameProperty
          • NoMarkupAttribute
          • ReplacementMarkerContents
          • TrimWhitespaceProperty
          • DeregisterMarkerProcessor(string)
          • Dispose()
          • ExpandSubstitutions(string,IList<string>)
          • ParseString(string,string,bool)
          • RegisterMarkerProcessor(string,IAttributeMarkerProcessor)
          • MarkupDiagnostic
            • MarkupDiagnostic(string,int)
            • Equals(object)
            • Equals(MarkupDiagnostic)
            • GetHashCode()
            • M:Yarn.Markup.LineParser.MarkupDiagnostic.op_Equality(Yarn.Markup.LineParser.MarkupDiagnostic,Yarn.Markup.LineParser.MarkupDiagnostic)
            • M:Yarn.Markup.LineParser.MarkupDiagnostic.op_Inequality(Yarn.Markup.LineParser.MarkupDiagnostic,Yarn.Markup.LineParser.MarkupDiagnostic)
            • Column
            • Message
        • MarkupAttribute
          • Shift(int)
          • ToString()
          • TryGetProperty(string,bool)
          • TryGetProperty(string,int)
          • TryGetProperty(string,float)
          • TryGetProperty(string,string?)
          • TryGetProperty(string,MarkupValue)
          • Length
          • Name
          • Position
          • Properties
        • MarkupParseException
        • MarkupParseResult
          • MarkupParseResult(string,List<MarkupAttribute>)
          • DeleteRange(MarkupAttribute)
          • TextForAttribute(MarkupAttribute)
          • TryGetAttributeWithName(string,MarkupAttribute)
          • Attributes
          • Text
        • MarkupProperty
          • Name
          • Value
        • MarkupValue
          • ToString()
          • ToString(IFormatProvider)
          • BoolValue
          • FloatValue
          • IntegerValue
          • StringValue
          • Type
        • MarkupValueType
          • Bool
          • Float
          • Integer
          • String
        • TagType
          • Close
          • CloseAll
          • Open
          • SelfClosing
      • Yarn.Compiler Namespace
        • CompilationJob
          • CompilationType
          • Declarations
          • Files
          • Library
          • CreateFromFiles(IEnumerable<string>,Library?)
          • CreateFromFiles(string[])
          • CreateFromString(string,string,Library?,int)
          • CancellationToken
          • LanguageVersion
          • TypeDeclarations
          • VariableDeclarations
          • File
            • FileName
            • Source
          • Type
            • DeclarationsOnly
            • FullCompilation
            • StringsOnly
            • TypeCheck
        • CompilationResult
          • GetDescriptionForVariable(string)
          • GetLabelsForNode(string)
          • GetStringForKey(string)
          • ContainsErrors
          • ContainsImplicitStringTags
          • DebugInfo
          • Declarations
          • Diagnostics
          • FileTags
          • Program
          • ProjectDebugInfo
          • StringTable
          • UserDefinedTypes
        • Compiler
          • Compile(CompilationJob)
          • FlattenParseTree(IParseTree)
          • GetDocumentComments(CommonTokenStream,ParserRuleContext,bool)
          • GetLineIDForNodeName(string)
        • Declaration
          • ExternalDeclaration
          • CreateVariable(string,IType,IConvertible,string?)
          • ToString()
          • DefaultValue
          • Dependencies
          • Dependents
          • Description
          • InitialValueParserContext
          • IsImplicit
          • IsInlineExpansion
          • IsVariable
          • Name
          • Range
          • SourceFileLine
          • SourceFileName
          • SourceNodeName
          • Type
        • DeclarationBuilder
          • WithDefaultValue(System.IConvertible)
          • WithDescription(string?)
          • WithImplicit(bool)
          • WithName(string)
          • WithRange(Yarn.Compiler.Range)
          • WithSourceFileName(string)
          • WithSourceNodeName(string)
          • WithType(IType)
          • Declaration
        • Diagnostic
          • Diagnostic(string,IToken,string,DiagnosticSeverity)
          • Diagnostic(string,ParserRuleContext?,string,DiagnosticSeverity)
          • Diagnostic(string,string,DiagnosticSeverity)
          • Diagnostic(string,DiagnosticSeverity)
          • Diagnostic(string,Range,string,DiagnosticSeverity)
          • Equals(object)
          • GetHashCode()
          • ToString()
          • Column
          • Context
          • FileName
          • Line
          • Message
          • Range
          • Severity
          • DiagnosticSeverity
            • Error
            • Info
            • Warning
        • EnumTypeBuilder
          • FromEnum(string?)
        • FileParseResult
          • FileParseResult(string,IParseTree,CommonTokenStream)
          • Equals(object)
          • GetHashCode()
          • Name
          • Tokens
          • Tree
        • FunctionTypeBuilder
          • FromFunctionType(System.Type)
          • WithParameter(IType)
          • WithReturnType(IType)
          • WithVariadicParameterType(IType?)
          • FunctionType
        • IndentAwareLexer
          • IndentAwareLexer(ICharStream,TextWriter,TextWriter)
          • IsInWhenClause()
          • NextToken()
          • SetInWhenClause(bool)
          • Warnings
          • LexerWarning
            • Message
            • Token
        • NodeDebugInfo
          • NodeDebugInfo(string?,string)
          • GetLineInfo(int)
          • FileName
          • IsImplicit
          • NodeName
          • Range
          • LineInfo
            • FileName
            • NodeName
            • Position
        • Position
          • Equals(object)
          • GetHashCode()
          • M:Yarn.Compiler.Position.op_GreaterThanOrEqual(Yarn.Compiler.Position,Yarn.Compiler.Position)
          • M:Yarn.Compiler.Position.op_LessThanOrEqual(Yarn.Compiler.Position,Yarn.Compiler.Position)
          • ToString()
          • Character
          • IsValid
          • Line
        • Project
          • CurrentProjectFileVersion
          • WorkspaceRootPlaceholder
          • YarnSpinnerProjectVersion2
          • YarnSpinnerProjectVersion3
          • Project()
          • Project(string,string?)
          • GetJson()
          • IsMatchingPath(string)
          • IsValidVersionNumber(int)
          • LoadFromFile(string,string?)
          • SaveToFile(string)
          • AllowLanguagePreviewFeatures
          • BaseLanguage
          • CompilerOptions
          • Definitions
          • DefinitionsFiles
          • DefinitionsPath
          • ExcludeFilePatterns
          • ExtensionData
          • FileVersion
          • Localisation
          • Path
          • SourceFilePatterns
          • SourceFiles
          • WorkspaceRootPath
          • LocalizationInfo
            • Assets
            • Strings
        • ProjectDebugInfo
          • GetNodeDebugInfo(string)
          • Nodes
        • Range
          • Range()
          • Range(int,int,int,int)
          • Equals(object)
          • GetHashCode()
          • ToString()
          • End
          • IsValid
          • Start
        • StringInfo
          • fileName
          • isImplicitTag
          • lineNumber
          • metadata
          • nodeName
          • shadowLineID
          • text
          • ToString()
        • Utility
          • AddTagsToLines(string,ICollection<string>?)
          • DetermineNodeConnections(string[])
          • ExtractStringBlocks(IEnumerable<Node>,ProjectDebugInfo)
          • GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration>,string,IEnumerable<string>?,IDictionary<string, string>?)
          • GetCompiledCodeAsString(Program,Library?,CompilationResult?)
          • GetYarnValue(IConvertible)
          • ParseSource(string)
          • TagLines(string,ICollection<string>?)
          • TryGetNodeTitle(string?,YarnSpinnerParser.NodeContext,string?,string?,string?,string?)
      • Yarn.Compiler.Upgrader Namespace
        • LanguageUpgrader
          • Upgrade(UpgradeJob)
        • TextReplacement
          • Comment
          • OriginalText
          • ReplacementText
          • Start
          • StartLine
          • OriginalLength
          • ReplacementLength
        • UpgradeJob
          • Files
          • UpgradeType
          • UpgradeJob(UpgradeType,IEnumerable<CompilationJob.File>)
        • UpgradeResult
          • Files
          • Diagnostics
          • OutputFile
            • Diagnostics
            • IsNewFile
            • OriginalSource
            • Path
            • Replacements
            • UpgradedSource
        • UpgradeType
          • Version1to2
      • Yarn.Unity Namespace
        • Actions
          • Actions(IActionRegistration,Library)
          • AddCommandHandler(string,Delegate)
          • AddCommandHandler(string,Func<object>)
          • AddCommandHandler(string,MethodInfo)
          • AddFunction(string,Delegate)
          • AddRegistrationMethod(ActionRegistrationMethod)
          • RegisterActions()
          • RegisterFunctionDeclaration(string,Type,Type[])
          • RemoveCommandHandler(string)
          • RemoveFunction(string)
          • SetupForProject(YarnProject)
          • ActionRegistrar
          • Commands
          • Library
        • BuiltinLocalisedLineProvider
          • DeregisterMarkerProcessor(string)
          • GetLocalizedLineAsync(Line,CancellationToken)
          • PrepareForLinesAsync(IEnumerable<string>,CancellationToken)
          • RegisterMarkerProcessor(string,Markup.IAttributeMarkerProcessor)
          • AssetLocaleCode
          • LocaleCode
        • Effects
          • FadeAlpha(CanvasGroup,float,float,float,CancellationToken)
          • FadeAlpha(CanvasGroup,float,float,float,CoroutineInterruptToken?)
          • FadeAlphaAsync(CanvasGroup,float,float,float,CancellationToken)
          • PausableTypewriter(TextMeshProUGUI,float,Action?,Action?,Action?,Stack<(int position, float duration)>?,CoroutineInterruptToken?)
          • Typewriter(TextMeshProUGUI,float,Action,CoroutineInterruptToken?)
          • CoroutineInterruptToken
            • Complete()
            • Interrupt()
            • Start()
            • CanInterrupt
            • WasInterrupted
        • ICommand
          • Name
        • ILineProvider
          • DeregisterMarkerProcessor(string)
          • GetLocalizedLineAsync(Line,CancellationToken)
          • PrepareForLinesAsync(IEnumerable<string>,CancellationToken)
          • RegisterMarkerProcessor(string,Yarn.Markup.IAttributeMarkerProcessor)
          • LocaleCode
          • YarnProject
        • LineProviderBehaviour
          • DeregisterMarkerProcessor(string)
          • GetLocalizedLineAsync(Line,CancellationToken)
          • PrepareForLinesAsync(IEnumerable<string>,CancellationToken)
          • RegisterMarkerProcessor(string,IAttributeMarkerProcessor)
          • Start()
          • LocaleCode
          • YarnProject
        • LocalizedLine
          • Asset
          • InvalidLine
          • Metadata
          • RawText
          • Substitutions
          • TextID
          • CharacterName
          • Text
          • TextWithoutCharacterName
        • MarkupPalette
          • BasicMarkers
          • CustomMarkers
          • ColorForMarker(string,Color)
          • PaletteForMarker(string,CustomMarker)
          • BasicMarker
            • Boldened
            • Color
            • CustomColor
            • Italicised
            • Marker
            • Strikedthrough
            • Underlined
          • CustomMarker
            • End
            • Marker
            • MarkerOffset
            • Start
        • RegistrationType
          • Compilation
          • Runtime
        • YarnActionAttribute
          • Name
        • YarnCommandAttribute
        • YarnFunctionAttribute
      • Yarn.Unity.UnityLocalization Namespace
        • LineMetadata
          • nodeName
          • tags
          • ShadowLineSource
        • UnityLocalisedLineProvider
          • DeregisterMarkerProcessor(string)
          • GetLocalizedLineAsync(Line,CancellationToken)
          • PrepareForLinesAsync(IEnumerable<string>,CancellationToken)
          • RegisterMarkerProcessor(string,IAttributeMarkerProcessor)
          • LocaleCode
    • Rust
      • bevy_yarnspinner
      • bevy_yarnspinner_example_dialogue_view
      • yarnspinner
Powered by GitBook
LogoLogo

Community

  • Discord
  • Bluesky
  • Mastodon

Support Our Work

  • Itch
  • Unity Asset Store
  • Patreon

Yarn Spinner® and Secret Lab® are trade marks of Secret Lab Pty. Ltd., and are used by Yarn Spinner Pty. Ltd. under license.

On this page

Was this helpful?

Edit on GitHub
Export as PDF

Last updated 6 hours ago

Was this helpful?

When you do things right, people won't be sure you've done anything at all. -

Introduction

Storylets and saliency represent an evolution in interactive storytelling techniques. To understand their significance, let's examine how narrative approaches have developed over time.

A lot of the terminology used here, and in Yarn Spinner, are based on the work by , and , and these are just great resources on the topic, go read them.

The Evolution of Interactive Storytelling

Linear Narratives

The earliest approach to storytelling was linear. Stories followed a single, author-defined path with each moment crafted to lead directly to the next.

Branching Narratives

The next evolution introduced branching, allowing stories to have multiple paths for players to explore.

Branching narratives offer remarkable flexibility. Some branches might be extensive with significant impact, while others could be minor, adding subtle flavor. Some paths might terminate, while others reconnect with the main storyline. Despite this flexibility, each step remains author-crafted, with branches fixed in the writer's intended order.

Storylet-Based Narratives

Storylets represent the next step in this evolution. They break the rigid connections between narrative elements, creating a more dynamic flow. Theoretically, a story could move from any storylet to any other storylet, creating a potential connection from every block to every other block.

Understanding Saliency

If narrative chunks are disconnected, how do they form a coherent experience? This is where saliency comes in—it's the mechanism that links story pieces together.

To be a bit more precise about this, saliency is the way Yarn Spinner does this. There are other approaches, the simplest being "present everything and let the player select the next piece".

Saliency determines which storylet is most relevant (or "salient") at any given moment. Instead of an author-defined sequence, saliency selects the ordering dynamically. For example, if you have two storylets—one about entering any room in an apartment, and another specifically about entering the bedroom—when the player is in the bedroom, the more specific storylet would be more salient.

Interestingly, linear and branching narratives can be viewed as salient stories composed of storylets, where the most salient storylet is defined by the author's explicit connections. This perspective highlights a major strength of storylets: they can incorporate and blend previous structural approaches. This gives you precise control when needed while maintaining flexibility for dynamic narrative progression.

You might be going "hang on, this sounds a lot like what [Classic Game] did, a game from ages ago I really enjoyed!?" and you'd be right, it is very similar. These ideas aren't new, nor was the evolution of these concepts as discrete as we've implied here.

Storylet Granularity

The storylet is the fundamental unit of this narrative system, but how large or small should a storylet be? The answer depends on your specific narrative needs.

Storylets typically exist at three levels of granularity:

  1. Collection Level: The largest unit—a vignette, conversation, or paragraph. At this level, your story assembles by connecting self-contained moments. These moments generally function independently, so their precise order may be flexible, or they might be designed to flow naturally with a subset of other moments.

  2. Line Level: Here, a storylet represents a single line of dialogue. Conversations build by assembling individual lines, which then form larger narrative moments. This approach is particularly effective for creating dynamic NPC barks in games.

  3. Sub-Line Level: The smallest unit, where storylets are fragments within a single line. These pieces combine to form complete lines of dialogue, which then assemble into conversations.

Many games blend these approaches, often mixing storylet techniques with traditional linear or branching content. Rather than focusing exclusively on storylet size, consider what type of narrative experience you want to create and determine what level of storylet granularity will best support that vision.

Types of Saliency

How do we determine which storylet is "best" to present next? The approach varies based on your narrative goals.

Quality-Based Saliency

The most common approach uses conditions on each storylet—boolean expressions like "are we in the bedroom?" or "does the player have more than 25 gold coins?" These conditions filter available storylets and help select among the remaining options. When multiple storylets are valid, you select the one with the highest "quality"—typically the one that satisfies the most conditions.

Tag-Based Saliency

Another approach tags storylets with various attributes. When selecting the next storylet, you filter based on relevant tags. The filtering criteria might come directly from player choices or from systems guiding the narrative.

Directed Saliency

Some approaches aim to guide the narrative toward specific outcomes:

  • Pathfinding: Storylets exist on a graph, and the system attempts to progress from the current storylet toward a specific destination, influenced by player choices along the way.

Simple Saliency Approaches

Two less complex but still useful approaches include:

  • Player Selection: Present all available storylets and let the player choose.

  • Random Selection: Choose randomly from available storylets.

These methods often incorporate knockout or deprioritization systems to prevent repetition. They're also effective for resolving ambiguity when multiple storylets have equal saliency.

Storylets in Practice

Storylets serve various narrative functions in games:

NPC Barks

Perhaps the most common use is creating contextual NPC comments. Skyrim's infamous "arrow to the knee" line exemplifies this—triggered when the player has cleared a dungeon, a condition most players eventually satisfy.

Environmental Flavor

Storylets create specific moments that add life to the game world without connecting directly to the main plot. Mass Effect's elevator conversations, filtered based on your current squad members, demonstrate this approach.

Contextual Reactions

Storylets can create highly specific dialogue responding to gameplay moments, making NPCs seem more aware and reactive. Left 4 Dead's combat and downtime barks showcase this, as do Ellie's contextual reactions in The Last of Us.

Emergent Narrative

In games without predetermined stories, storylets create meaningful moments and side-narratives. Civilization VII uses storylets for historical and alternative historical events, triggered by factors like civilization type, leaders, and current player actions.

Explorable Narratives

Database-driven games use storylets to let players explore narrative space freely. Her Story exemplifies this approach, with self-contained story chunks that both stand alone and contribute to an overall narrative.

Complete Narrative Systems

Some games build entire narratives from storylets. Mask of a Rose and Wildermyth assemble stories entirely from storylets based on player actions, allowing players to create their own unique narratives.

Many of these games haven't talked about their approaches as using storylets, but its much easier to talk about it using the terminology already in this guide rather than use the terms the devs themselves said which are different for each game.

Storylets in Yarn Spinner

Yarn Spinner supports two primary levels of storylet granularity: line-based and node-based. Both integrate seamlessly with traditional branching and linear Yarn scripts.

Line Groups

Line Groups implement line-level storylets. They visually resemble option groups but use => instead of ->. Each line within a group represents a potential storylet, but only one will be selected.

The dialogue system receives the Barry line, then one selected line from Alice. The player might see:

The system doesn't indicate that the Alice line came from a storylet selection—it's simply presented as the next line of dialogue.

We can add conditions to modify selection:

Assuming high Barry suspicion and knowledge that he's a cop, the dialogue might present:

The final line is selected as the most salient option, even though multiple options satisfy their conditions.

Like option groups, line groups support nested content that only appears if that specific line is chosen:

Any Yarn dialogue or commands can be nested, including other storylets, jumps, and detours.

Node Groups

Node groups allow larger storylet chunks to be associated. They look like standard nodes but require a when header:

When <<jump Alice>> executes, it jumps to the most salient node in the "Alice" group. If Barry is highly suspicious and Alice knows he's a cop, the system selects the last node.

For this simple example, node groups require more writing than line groups for the same effect. However, for larger conversations with significant variability, node groups become more advantageous.

You might notice that you can have as many when headers as you want on a node storylet. You might also notice the when: always header on one of the storylets, this is required with node groups to say "this one is always available".

Like line groups, node groups can contain any valid Yarn content, including jumps, detours, and line groups.

Saliency Strategies

The dialogue runner consults a saliency strategy when presenting a storylet, whether from a line group or node group. While you can create custom strategies to implement any approach, Yarn Spinner provides several built-in quality-based strategies:

  • Best (select the most salient)

  • Best Least Recently Viewed (prioritize salient content that hasn't been seen recently)

  • Random Best Least Recently Viewed (like above, with some randomization)

  • Random (completely random selection)

All built-in strategies first filter out storylets with failing conditions, though custom strategies can include failing conditions if desired.

The recommended default is Random Best Least Recently Viewed, which balances selection of the highest-saliency content while preventing repetition.

If you are ever after a great breakdown of some of the most common shapes and patterns in branching narrative check out .

Drama Management: A system with narrative goals selects storylets to work toward those goals. For example, selects storylets to maximize conversational drama. Pathfinding can be viewed as drama management where the goal is reaching a specific point in the narrative graph.

Barry: Oh is that so?

=> Alice: Yep.
=> Alice: Of course it is!
=> Alice: Why would you think otherwise?
Barry: Oh is that so?
Alice: Of course it is!
Barry: Oh is that so?

=> Alice: Yep.
=> Alice: Of course it is! <<if $barry_suspicion > 3>>
=> Alice: Why would you think otherwise? <<if $barry_suspicion > 5>>
=> Alice: I am not talking without my lawyer <<if $barry_suspicion > 5 && $knows_barry_is_cop>>
Barry: Oh is that so?
Alice: I am not talking without my lawyer
Barry: Oh is that so?

=> Alice: Yep.
    Barry: lol lmao, thanks nerd.
=> Alice: Of course it is! <<if $barry_suspicion > 3>>
=> Alice: Why would you think otherwise? <<if $barry_suspicion > 5>>
=> Alice: I am not talking without my lawyer <<if $barry_suspicion > 5 && $knows_barry_is_cop>>
    Barry: Why would you need a lawyer?
    Alice: *cool silence*
title: Barry
---
Barry: Oh is that so?
<<jump Alice>>
===

title: Alice
when: always
---
Alice: Yep.
Barry: lol lmao, thanks nerd.
===

title: Alice
when: $barry_suspicion > 3
---
Alice: Of course it is!
===

title: Alice
when: $barry_suspicion > 5
---
Alice: Why would you think otherwise?
===

title: Alice
when: $barry_suspicion > 5
when: $knows_barry_is_cop
---
Alice: I am not talking without my lawyer
Barry: Why would you need a lawyer?
Alice: *cool silence*
===
  1. Writing Yarn Scripts
  2. Advanced Scripting

Storylets and Saliency Primer

Learn the principles behind our storylets and saliency features.

PreviousNode GroupsNextSaliency
  • Introduction
  • The Evolution of Interactive Storytelling
  • Understanding Saliency
  • Storylet Granularity
  • Types of Saliency
  • Storylets in Practice
  • Storylets in Yarn Spinner
Kabo Ashwell (2015)
Façade
Futurama
Emily Short (2019)
Kreminksi and Wardrip-Fruin (2018)
A linear story
A branching story
A freeform story
Combining linear, branching, and storylet storytelling
The fundamental particles, including the Storylet. Modified image from Wikipedia