YarnLine
A line of dialogue with substitution, markup, and localisation support.
class_name YarnLine
extends RefCountedInherits from RefCounted
Access text and character_name directly — substitutions and markup are applied lazily on first access. For raw data, use raw_text and substitutions.
#Properties
#character_name
Character name extracted from [character] markup or implicit "Name:" pattern. Computed lazily alongside text.
var character_name: StringType String
#line_id
The string table ID for this line (e.g. "line:tutorial-tom-01").
var line_id: String = ""Type String
#locale_code
BCP-47 locale for [plural] and [ordinal] rules.
var locale_code: String = "en"Type String
#markup_attributes
Parsed markup attributes — populated on first access to text.
var markup_attributes: Array[YarnMarkupAttribute] = []#markup_result
Full markup parse result — populated on first access to text.
var markup_result: YarnMarkupParseResult = null#metadata
#hashtag metadata from the yarn source.
var metadata: PackedStringArray = PackedStringArray()Type PackedStringArray
#raw_text
Localised text before substitution — still contains {0} placeholders and markup tags. Set by the line provider.
var raw_text: String = ""Type String
#source
Optional source that handles requests to end this line early. The dialogue runner sets this to itself when it dispatches the line to its presenters. Wrapper presenters (such as the Interruption add-on) may substitute themselves as the source so that requests from child presenters to end the line can be intercepted. A source object should implement
request_line_cancellation(line: YarnLine). Presenters should route end-of-line requests through YarnDialoguePresenter._request_line_end, which uses this field if set and otherwise falls back to calling YarnDialogueRunner.signal_content_complete directly.var source: Object = nullType Object
#substitutions
Values replacing {0}, {1}, etc. placeholders in raw_text.
var substitutions: Array[String] = []Type Array[String]
#text
Final text after substitution and markup processing. Computed lazily on first access.
var text: StringType String
#text_without_character_name
The text with the character name prefix removed.
var text_without_character_name: StringType String
#Methods
#apply_substitutions()
Substitutions and markup are now applied automatically on first access to text. This method triggers processing early if needed.
func apply_substitutions() -> void#delete_attribute_text(YarnMarkupAttribute)
Deletes the text covered by an attribute and re-parses.
func delete_attribute_text(attr: YarnMarkupAttribute) -> voidParameters
#get_bbcode_text(YarnMarkupParser, bool)
Returns text with markup converted to BBCode for RichTextLabel.
func get_bbcode_text(parser: YarnMarkupParser = null, include_character_name: bool = false) -> StringParameters
parserYarnMarkupParserinclude_character_namebool
Returns String
#get_markup_result_without_character_name()
func get_markup_result_without_character_name() -> YarnMarkupParseResultReturns YarnMarkupParseResult
#get_markup_result()
Ensures processing, then returns the full markup result.
func get_markup_result() -> YarnMarkupParseResultReturns YarnMarkupParseResult
#get_plain_text()
Returns text_without_character_name (substitutions and markup already applied).
func get_plain_text() -> StringReturns String
#invalidate()
Force reprocessing (e.g. if raw_text or substitutions changed after creation).
func invalidate() -> void#parse_markup()
Markup is now parsed automatically on first access to text. This method triggers processing early if needed.
func parse_markup() -> void#set_markup_result(YarnMarkupParseResult)
#text_for_attribute(YarnMarkupAttribute)
Returns the substring of text covered by an attribute.
func text_for_attribute(attr: YarnMarkupAttribute) -> StringParameters
Returns String
#try_get_attribute(String)
Returns the first attribute with the given name, or null.
func try_get_attribute(attr_name: String) -> YarnMarkupAttributeParameters
attr_nameString
Returns YarnMarkupAttribute
Generated from Yarn Spinner for Godot GDScript 3.3.