Documentation
¶
Overview ¶
Lua language support.
Index ¶
- func Run[T LuaRetTypes](script string, ops ...func(*glua.LState)) (T, error)
- func RunFile[T LuaRetTypes](path string, ops ...func(*glua.LState)) (T, error)
- func RunReader[T LuaRetTypes](f io.Reader, ops ...func(*glua.LState)) (T, error)
- func WithGlobalBool(name string, v bool) func(*glua.LState)
- func WithGlobalNil(name string) func(*glua.LState)
- func WithGlobalNum(name string, v float64) func(*glua.LState)
- func WithGlobalStr(name string, v string) func(*glua.LState)
- func WithGlobalStrTable(name string, m map[string]any) func(*glua.LState)
- func WithLogger(rail Log) func(l *glua.LState)
- type Log
- type LuaRetTypes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run[T LuaRetTypes](script string, ops ...func(*glua.LState)) (T, error)
Run Lua Script.
Use With***() funcs to set global variables.
If WithLogger is provided, infof(...) and errorf(...) are builtin funcs that can be called inside the lua scripts for logging.
If WithLogger is not provided, you can still use infof(...), errorf(...) and printf(...), logs are written directly to stdout.
E.g., WithGlobalStr, WithGlobalNum, WithGlobalBool
func RunFile ¶
func RunFile[T LuaRetTypes](path string, ops ...func(*glua.LState)) (T, error)
Run Lua Script File.
See Run
func WithGlobalNil ¶
func WithGlobalStrTable ¶
Set table to global field.
Values in map must be one of the types: string, int, int8, int16, int32, int64, float32, float64, and bool; if not, the value is ignored.
func WithLogger ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.