package act

import "git.teletypegames.org/engines/inkwell/act"

Package act holds the adventure actions: the ones that need more of the game than the inkbase.State in the Ctx — speech, the inventory, dialogs, scene changes, walking, poses, the voice setting and the end card. Each action type-asserts ctx.Game to the narrow host interface it needs (SpeechHost, InventoryHost, DialogHost, SceneHost, MovementHost, PoseHost, VoiceHost, EndCardHost, FlashHost), and an inkwell *Game satisfies all of them. Games normally use the re-exports in the root inkwell package, which take the entities themselves (a *Scene, a *Character) where these take names.

The generic actions and the combinators (Seq, Par, If, Wait, SetFlag, …) live in the inkbase/action package, which also describes the Action and Runner model and how to write an action of your own.

The actions

For example, a hotspot that only opens with the key in hand:

OnUse: inkwell.Seq(
	inkwell.RequireItem(key),
	inkwell.Say(paul, inkwell.Text{{Lang: "en", Text: "Click."}}),
	inkwell.SetFlag("door_open"),
),

Index

Variables

var MsgNeedItem = inkbase.Text{
	{Lang: "en", Text: "I'd need a %s for that."},
	{Lang: "hu", Text: "Ehhez kellene egy %s."},
}

MsgNeedItem is what RequireItem says when the player hasn't got the item. %s is the item label.

Functions

func Back

func Back() inkbase.Action

Back returns to the scene the player came from.

func EndDialog

func EndDialog() inkbase.Action

EndDialog closes the open conversation.

func Flash

func Flash(text inkbase.Text) inkbase.Action

Flash puts a line in the status strip for about two seconds.

func Give

func Give(item *item.Item) inkbase.Action

Give puts an item in the inventory.

func GoTo

func GoTo(scene string) inkbase.Action

GoTo takes the player to another scene, through the scene fade. The scene is identified by name; the root wrapper converts *Scene to name.

func GotoNode

func GotoNode(node string) inkbase.Action

GotoNode moves the open conversation to another of its nodes.

func Reply

func Reply(speaker inkbase.Talker, answer func(state *inkbase.State) inkbase.Text) inkbase.Action

Reply is Say with the line decided when it is spoken.

func RequireItem

func RequireItem(item *item.Item) inkbase.Action

RequireItem fails the sequence, with a flash line, unless the item is held.

func RunDialog

func RunDialog(dialog *dialog.Dialog) inkbase.Action

RunDialog opens a dialog tree and holds the script until it closes.

func Say

func Say(speaker inkbase.Talker, text inkbase.Text) inkbase.Action

Say puts one line in a character's mouth.

func SetPose

func SetPose(character string, pose sprite.Pose) inkbase.Action

SetPose holds a character in a pose until the character next walks or speaks. The character is identified by name; the root wrapper converts *Character to name.

func SetVoice

func SetVoice(on bool) inkbase.Action

SetVoice switches recorded lines on or off and saves the settings.

func ShowEnd

func ShowEnd(text inkbase.Text) inkbase.Action

ShowEnd puts the end card up and never finishes: the game is over.

func TakeAway

func TakeAway(item *item.Item) inkbase.Action

TakeAway removes an item from the inventory.

func Walk

func Walk(character string, to inkbase.Point) inkbase.Action

Walk sends a character to a point through the walkboxes and holds the script until it arrives. The character is identified by name; the root wrapper converts *Character to name.

Types

type DialogHost

type DialogHost interface {
	StartDialog(d *dialog.Dialog)
	DialogActive() bool
	EndDialog()
	GotoDialogNode(name string)
}

DialogHost is the slice of *Game a dialog action needs.

type EndCardHost

type EndCardHost interface {
	ShowEndCard(text string)
}

EndCardHost is the slice of *Game a ShowEnd action needs.

type FlashHost

type FlashHost interface {
	FlashLine(text inkbase.Text)
}

FlashHost is the slice of *Game a Flash action needs.

type InventoryHost

type InventoryHost interface {
	InventoryAdd(name string)
	InventoryRemove(name string)
	InventoryHas(name string) bool
	FlashLine(text inkbase.Text)
	ItemLabel(name string) inkbase.Text
}

InventoryHost is the slice of *Game an inventory action needs.

type MovementHost

type MovementHost interface {
	WalkCharacter(name string, to inkbase.Point)
	CharacterMoving(name string) bool
}

MovementHost is the slice of *Game a Walk action needs.

type PoseHost

type PoseHost interface {
	SetCharacterPose(name string, pose sprite.Pose)
}

PoseHost is the slice of *Game a SetPose action needs.

type SceneHost

type SceneHost interface {
	ChangeScene(name string)
	PreviousScene() string
}

SceneHost is the slice of *Game a scene-change action needs.

type SpeechHost

type SpeechHost interface {
	NoteSpoken(name string)
	DeliveryOf(name string) inkbase.Delivery
	SetSpeech(speaker, text string)
	ClearSpeech()
	LogResponse(speaker, text string)
	Talking() string
	SetTalking(name string)
	VoiceOn() bool
	PlayVoice(v *inkbase.Voice) float64
	StopVoice()
	ConsumedClick() bool
}

SpeechHost is the slice of *Game a Say or Reply action needs.

type VoiceHost

type VoiceHost interface {
	SetVoiceEnabled(on bool)
	StopVoice()
	SaveSettings() error
}

VoiceHost is the slice of *Game a SetVoice action needs.