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
- Say shows a line over the speaker (a speech bubble, or the log alone for a DeliveryLog speaker) and appends it to the chat log. A click skips it. It lasts as long as the line's recorded inkbase.Voice when voices are on, otherwise a time that scales with the resolved text's length, 1.2 seconds at least. The speaker becomes known.
- Reply is Say with the line decided when it is spoken: answer is handed the State and returns the Text for this moment, so a speaker can answer from what the player has done without a dialog node per case.
- Give adds an item to the inventory and marks it known; TakeAway removes it.
- RequireItem flashes MsgNeedItem and fails — stopping the sequence it is in — unless the item is held.
- RunDialog opens a dialog and holds the script until it closes; EndDialog closes the open one, and GotoNode moves it to another of its nodes.
- GoTo changes scene through the scene fade; Back returns to the previous scene, and does nothing when there is none.
- Walk sends a character to a point through the walkboxes and holds the script until it arrives.
- SetPose holds a character in a pose until it next walks or speaks.
- SetVoice switches recorded lines on or off and saves the settings.
- Flash puts a line in the status strip for about two seconds.
- ShowEnd puts the end card up and never finishes: the game is over.
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
- func Back() inkbase.Action
- func EndDialog() inkbase.Action
- func Flash(text inkbase.Text) inkbase.Action
- func Give(item *item.Item) inkbase.Action
- func GoTo(scene string) inkbase.Action
- func GotoNode(node string) inkbase.Action
- func Reply(speaker inkbase.Talker, answer func(state *inkbase.State) inkbase.Text) inkbase.Action
- func RequireItem(item *item.Item) inkbase.Action
- func RunDialog(dialog *dialog.Dialog) inkbase.Action
- func Say(speaker inkbase.Talker, text inkbase.Text) inkbase.Action
- func SetPose(character string, pose sprite.Pose) inkbase.Action
- func SetVoice(on bool) inkbase.Action
- func ShowEnd(text inkbase.Text) inkbase.Action
- func TakeAway(item *item.Item) inkbase.Action
- func Walk(character string, to inkbase.Point) inkbase.Action
- type DialogHost
- type EndCardHost
- type FlashHost
- type InventoryHost
- type MovementHost
- type PoseHost
- type SceneHost
- type SpeechHost
- type VoiceHost
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.