lua

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lua

type Lua struct {
	// contains filtered or unexported fields
}

Lua implements skit.Handler using a lua scripting layer.

func New

func New(src, handlerName string, luaPaths []string) (*Lua, error)

New initializes the Lua based skit handler.

func (*Lua) Handle

func (lh *Lua) Handle(ctx context.Context, sk *skit.Skit, ev *skit.MessageEvent) bool

Handle dispatches the event object to lua handler function and returns the result.

type Wrapper

type Wrapper struct {
	// contains filtered or unexported fields
}

Wrapper is a thin wrapper around gopher-lua defined lua state

func NewWrapper

func NewWrapper(paths ...string) *Wrapper

NewWrapper initializes a new wrapper with empty Lua state

func (*Wrapper) Bind

func (wr *Wrapper) Bind(name string, v interface{})

Bind creates a global variable with given value and name thus exposing the value to the lua script

func (*Wrapper) BindAll

func (wr *Wrapper) BindAll(vals map[string]interface{})

BindAll exposes all the values in the map to the lua scripts by iteratively calling Bind with key and value

func (*Wrapper) Call

func (wr *Wrapper) Call(name string, args ...interface{}) (lua.LValue, error)

Call a lua function by its name. Args are automatically converted to appropriate types using the Luar library

func (*Wrapper) CallFunc

func (wr *Wrapper) CallFunc(lfn *lua.LFunction, args ...interface{}) (lua.LValue, error)

CallFunc calls the given lua function object with given args.

func (*Wrapper) Execute

func (wr *Wrapper) Execute(src string) error

Execute the given lua script string

func (*Wrapper) ExecuteFile

func (wr *Wrapper) ExecuteFile(fileName string) error

ExecuteFile reads and executes the lua file

func (*Wrapper) GetFunction

func (wr *Wrapper) GetFunction(name string) (*lua.LFunction, error)

GetFunction returns a function object defined in Lua if found.

func (*Wrapper) Reset

func (wr *Wrapper) Reset()

Reset the lua state. Same as creating new instance of Wrapper

func (*Wrapper) State

func (wr *Wrapper) State() *lua.LState

State returns the actual lua state object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL