luautil

package
v0.0.0-...-890d60c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package luautil embeds Lua VM into Go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PullArbitraryValue

func PullArbitraryValue(l *lua.State, remove bool) interface{}

func PushTableFromMap

func PushTableFromMap(l *lua.State, v reflect.Value)

func PushTableFromSlice

func PushTableFromSlice(l *lua.State, v reflect.Value)

func PushTableFromStruct

func PushTableFromStruct(l *lua.State, v reflect.Value)

func RunFile

func RunFile(ctx context.Context, filename string) (interface{}, bool)

RunFile is similar to RunInline, except it takes in a filename which has the lua code to run. Note that the file's contents are cached, so the file is only opened and read the first time it's used.

func RunInline

func RunInline(ctx context.Context, code string) (interface{}, bool)

RunInline takes the given lua code, and runs it with the given ctx variable set as the lua global variable "ctx". The lua code is expected to return a boolean value, which is passed back as the first boolean return. The second boolean return will be false if there was an error and the code wasn't run

Types

type LuaRunner

type LuaRunner struct {
	File   string `yaml:"lua_file"`
	Inline string `yaml:"lua_inline"`
}

LuaRunner performs some arbitrary lua code. The code can either be sourced from a file or from a raw string (Inline).

func (*LuaRunner) Do

func (l *LuaRunner) Do(c context.Context) (interface{}, bool)

Do performs the actual lua code, returning whatever the lua code returned, or false if there was an error

Jump to

Keyboard shortcuts

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