Documentation ¶
Index ¶
- type Distributor
- type Module
- type Script
- func (script *Script) Close() error
- func (script *Script) Global(name string) (v Value, ok bool)
- func (script *Script) PreloadModule(mod *Module)
- func (script *Script) RunFile(file string) error
- func (script *Script) RunStdin()
- func (script *Script) RunString(lua string) error
- func (script *Script) SetGlobal(name string, value lua.LValue)
- func (script *Script) SetModule(mod *Module)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Distributor ¶
type Distributor struct {
// contains filtered or unexported fields
}
Distributor continuously scans the stdin for new script code written to it, and broadcasts it to any scripts that are subscribed to it.
func Distribute ¶
func Distribute(reader io.Reader) *Distributor
Distribute starts distributing code lines read from the reader to all subscribes of the distributor.
func (*Distributor) Subscribe ¶
func (distributor *Distributor) Subscribe(script *Script)
Subscribe subscribes a script to all code distributed by the distributor.
type Module ¶
Module represents a module in a script. It may either be set by the Go program directly, or pre-loaded so that the script itself can 'require()' it.
func NewModule ¶
NewModule returns a new initialised module using the name passed. It has no fields or functions set, but may set to the script.
type Script ¶
type Script struct { // ErrorLog is a log.Logger that errors that occur during the interpreting of Lua code. By default, it is // set to the package level log variable. ErrorLog *log.Logger // contains filtered or unexported fields }
Script is a wrapper around a Lua state. It provides methods to easily add globals and modules to the script from the Go side.
func (*Script) Global ¶
Global returns a global value from the script. The global may be either set from the Go side or the script's side.
func (*Script) PreloadModule ¶
PreloadModule pre-loads a script module so that it may be imported in the script using 'require()'. It must be done by the script itself. For the module to be set directly so that the script doesn't have to use 'require()', see SetModule.
func (*Script) RunStdin ¶
func (script *Script) RunStdin()
RunStdin starts interpreting the stdin as Lua code. It reports any errors during interpreting to the ErrorLog logger of the script. Multiline code may be encapsulated within double quotes ("") to await execution until the ending double quotes have been written.
func (*Script) RunString ¶
RunString runs a string of Lua source code passed. Multiple strings may be ran successively in order to create a continuously running script.
type Value ¶
type Value struct {
lua.LValue
}
Value represents a value that may be fed into a script and taken out of a script. Scripts may operate on these values.
func ValueOf ¶
func ValueOf(value interface{}) Value
ValueOf converts a basic scalar value to a value that may be used to feed into the script. It panics if returned if the value's type is not one of bool, uint8, int8, uint16, int16, uint32, int32, uint64, int64, uint, int, float32, float64, string or nil.