Yarnspinnex.Cursor (yarnspinnex v0.3.0)

Copy Markdown View Source

A position in a running dialogue: the current node, the path into it, the variables the dialogue owns (keyed by bare name, so $gold in a script is "gold" here), and the fingerprint of the node it is in. Plain data with no reference to the script itself and none of the host's context, so it can be persisted (:erlang.term_to_binary/1), copied, and resumed later.

Summary

Types

Which branch of an <<if>> (by position, or :else) or which option of a group was taken.

t()

path lists the enclosing <<if>>/option groups innermost first, each as the statement index of that construct in its own list plus the selector taken; index is the next statement in the innermost list. fingerprint is the node's entry in Yarnspinnex.Script fingerprints.

Types

selector()

@type selector() :: {:if, non_neg_integer() | :else} | {:option, non_neg_integer()}

Which branch of an <<if>> (by position, or :else) or which option of a group was taken.

t()

@type t() :: %Yarnspinnex.Cursor{
  fingerprint: non_neg_integer(),
  index: non_neg_integer(),
  node: String.t(),
  path: [{non_neg_integer(), selector()}],
  vars: %{optional(String.t()) => term()}
}

path lists the enclosing <<if>>/option groups innermost first, each as the statement index of that construct in its own list plus the selector taken; index is the next statement in the innermost list. fingerprint is the node's entry in Yarnspinnex.Script fingerprints.