Documentation
¶
Overview ¶
Package dialog is conversations written as data: nodes of lines and answers a Stage loads from YAML files, held by its entities and answered by a player through a window pinned to the speaker. What a conversation changes in the game is the game's own components, changed and asked by name.
Nodes ¶
A Node is who speaks, what is said and the answers offered, each a Choice: its words, when it is offered (If), what it changes (Then), where it leads (Next, or End) and the commands it gives (Do). Plugin.Load reads a file of them by name, Plugin.Define says one in code, both in the plugin's own section of a Stage, Conversations:
greet:
speaker: Miller
say: ["Hello, traveller!"]
choices:
- text: "Good to see you again!"
if: friend
next: glad
- text: "Out of my way."
then: [offend]
next: end
Changes and conditions ¶
Plugin.Changes are what answers change, by name: Alter a function of the speaker's component and the listener, AlterListener of the listener's and the speaker. Plugin.Conditions are when answers are offered, by name: When a function of the speaker's component and the listener. An answer's if may name an effect the speaker is under instead, "!" denying it. A rule changes the game the same way with Feel.
Conversations ¶
An entity's conversations begin where its Script says, or at the node a Begin names; a Begin is the entity's own, about whom it talks with. The conversation is the speaker's Talk; TalkingEf is on the speaker while it talks and TalkedEf for a while after one talked to the end (Plugin.DefineEffects). A Choose answers, given by a button of Plugin.Window, by a player the listener obeys.
Window ¶
Plugin.Window is one ui element for every speaker, pinned Under TalkingEf: its title the speaker, what is said, a button for each answer offered. Plugin.SpeakerText, Plugin.LineText and Plugin.ChoiceText lay out a window of a game's own.
Vocabulary ¶
Commands: Begin, Feel (an entity's own, aimed at the moment's subject, host.Aimed); Choose (a player's, from the window's button, ui.About). Effects: TalkingEf, TalkedEf.
Index ¶
- Constants
- Variables
- func Conversations(f func(d *Plugin) error) section.Section
- type Begin
- type Change
- type Changes
- type Choice
- type Choose
- type Condition
- type Conditions
- type Config
- type Feel
- type Node
- type Plugin
- func (p *Plugin) Changes() *Changes
- func (p *Plugin) ChoiceText(index int) ui.Text
- func (p *Plugin) Conditions() *Conditions
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) Define(name string, n Node)
- func (p *Plugin) DefineEffects()
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Install(ctx plugin.Installer) error
- func (p *Plugin) LineText() ui.Text
- func (p *Plugin) Load(fsys fs.FS, path string) error
- func (p *Plugin) Name() string
- func (p *Plugin) Queues() []command.CommandQueue
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Script(node string) Script
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) SpeakerText() ui.Text
- func (p *Plugin) Window() *ui.Element
- type Script
- type Talk
Constants ¶
const ( TalkingEf = "dialog.talking" TalkedEf = "dialog.talked" )
The names of the plugin's effects: TalkingEf is on the speaker while it talks, and taken off the conversation is over; TalkedEf is on it for Config.Rest after one talked to the end.
const End = "end"
End is the Next of an answer that ends the conversation.
const MaxChoices = 6
MaxChoices is how many answers a node offers at most.
Variables ¶
var ConversationsPart = section.Define("Conversations", section.Commands, section.Kinds)
ConversationsPart is the dialog plugin's part of a Stage's definition, after its commands and before its kinds.
Functions ¶
Types ¶
type Begin ¶
type Begin struct {
At string
// contains filtered or unexported fields
}
Begin is the command by which an entity begins to talk with whom it is aimed at, at the node At or where its Script says. It is refused while either of them talks already.
type Change ¶
type Change struct {
// contains filtered or unexported fields
}
Change is what an answer changes in the game, made by Alter or AlterListener.
type Changes ¶
type Changes struct {
// contains filtered or unexported fields
}
Changes is the register of what answers change in the game, by name.
type Choice ¶
type Choice struct {
Text string `yaml:"text"`
// If is a condition the game defined or the name of an effect the speaker is under, "!"
// before it denying; empty, the answer is always offered.
If string `yaml:"if"`
Then []string `yaml:"then"`
Next string `yaml:"next"`
Do []string `yaml:"do"`
}
Choice is one answer: its words, when it is offered, what it changes, where it leads and the commands it gives.
type Choose ¶
Choose is the answer Index of those offered now in Speaker's conversation. Only a player the listener obeys may choose.
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition is when an answer is offered, made by When.
type Conditions ¶
type Conditions struct {
// contains filtered or unexported fields
}
Conditions is the register of when answers are offered, by name.
func (*Conditions) Define ¶
func (c *Conditions) Define(name string, cond Condition)
Define registers cond as name. A name defined twice, one an effect bears, or a Condition not made by When panics.
type Feel ¶
type Feel struct {
Change string
// contains filtered or unexported fields
}
Feel is the command by which an entity undergoes the game's change called Change towards whom it is aimed at, as if it spoke and that one answered.
type Node ¶
type Node struct {
Speaker string `yaml:"speaker"`
Say []string `yaml:"say"`
Choices []Choice `yaml:"choices"`
}
Node is one place of a conversation: who speaks, what is said, and the answers offered, at most MaxChoices.
type Plugin ¶
Plugin carries conversations: the nodes a Stage defines and the Talks its entities hold.
func (*Plugin) ChoiceText ¶
ChoiceText is the words of the answer offered at index in the conversation of the entity an element is pinned to; nothing past the last offered.
func (*Plugin) Conditions ¶
func (p *Plugin) Conditions() *Conditions
Conditions are when answers are offered, by name.
func (*Plugin) DefaultBindings ¶
DefaultBindings is none: a conversation is begun by rules and answered by the window's buttons.
func (*Plugin) Define ¶
Define says the node called name in code. A name defined twice, an unknown change or condition, or too many answers panics.
func (*Plugin) DefineEffects ¶
func (p *Plugin) DefineEffects()
DefineEffects defines TalkingEf and TalkedEf in the Stage's world. Call it where the Stage defines its effects.
func (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
EventHandler is nil: the window's buttons give Choose.
func (*Plugin) LineText ¶
LineText is what is said in the conversation of the entity an element is pinned to.
func (*Plugin) Load ¶
Load reads the nodes of the YAML file at path in fsys, a map of Nodes by name, and defines them.
func (*Plugin) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are the plugin's command queues: Begin, Choose and Feel.
func (*Plugin) RunPlan ¶
RunPlan carries the conversations on in the simulation. Call it after the plugins whose rules begin them.
func (*Plugin) Script ¶
Script is the component of a kind whose conversations begin at the node called node. An unknown node panics.
func (*Plugin) Serializable ¶
func (p *Plugin) Serializable() plugin.Serializable
Serializable is nil: the conversations are components, saved with their entities.
func (*Plugin) SpeakerText ¶
SpeakerText is who speaks in the conversation of the entity an element is pinned to.