Documentation ¶
Index ¶
- func Compile(options ...CompileArg) error
- func NoCodeFolding(ca *CompileArgs)
- func NoDeadCodeElimination(ca *CompileArgs)
- type CompileArg
- type CompileArgs
- type EndScript
- type EnterNode
- type ExecutionType
- type ExitNode
- type FunctionCall
- type Handler
- type HandlerFunc
- type Message
- type MessageType
- type Process
- type Script
- type ScriptOption
- type ShowChoice
- type ShowLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(options ...CompileArg) error
Compile tranlates a Script from text into its executable form. Any reads errors, syntax errors, semantic errors, or write errors will result in an error being returned.
func NoCodeFolding ¶
func NoCodeFolding(ca *CompileArgs)
func NoDeadCodeElimination ¶
func NoDeadCodeElimination(ca *CompileArgs)
Types ¶
type CompileArg ¶
type CompileArg func(*CompileArgs)
func CompilerInput ¶
func CompilerInput(r io.Reader) CompileArg
func CompilerOutput ¶
func CompilerOutput(w io.Writer) CompileArg
type CompileArgs ¶
type CompileArgs struct {
// contains filtered or unexported fields
}
type ExecutionType ¶
type ExecutionType vm.ExecutionType
ExecutionType as a handler's return value is a signal to the Process whether or not to carry on executing once a callback is handled.
const ( // Returning Pause will cause the Process to suspend until its // Continue() method is invoked. Pause ExecutionType = ExecutionType(vm.PauseExecution) // Returning Continue will cause the Process to continue executing // and will not stop until either the dialogue ends, an option is // shown, or one of the other ScriptHandler methods returns Pause Continue ExecutionType = ExecutionType(vm.ContinueExecution) )
type FunctionCall ¶
type FunctionCall struct { Name string Args []interface{} }
type Handler ¶
type Handler interface {
Handle(m Message) ExecutionType
}
Handler is the Process's interface to the rest of the program. This method is used to handle messages coming from the process.
type HandlerFunc ¶
type HandlerFunc func(m Message) ExecutionType
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(m Message) ExecutionType
type Message ¶
type Message struct { Type MessageType ShowLine EnterNode ExitNode EndScript ShowChoice FunctionCall }
type MessageType ¶
type MessageType int
const ( EndScriptType MessageType = iota ShowLineType EnterNodeType ExitNodeType ShowChoiceType FunctionCallType )
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is an instance of a script to execute. Run the script by invoking the Start() method.
func (*Process) ChooseAndResume ¶
ChooseAndResume continues a Process which is waiting for user input. Calling this on a Process which isn't waiting for user input will result in an error.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script is a compiled script. Running this spawns a Process, which will run the dialogue logic.
func FromReader ¶
func FromReader(opts ...ScriptOption) (*Script, error)
FromReader loads a compiled script from a file or other reader.
type ScriptOption ¶
type ScriptOption struct {
// contains filtered or unexported fields
}
func IsUncompressed ¶
func IsUncompressed() ScriptOption
func ScriptInput ¶
func ScriptInput(r io.Reader) ScriptOption
type ShowChoice ¶
type ShowChoice struct {
Options []string
}