Versions in this module Expand all Collapse all v0 v0.1.0 Aug 1, 2026 Changes in this version + var ErrCapacity = errors.New("lua: capacity hint is too large") + var ErrClosed = errors.New("lua: state is closed") + var ErrForeignValue = errors.New("lua: value belongs to another state") + var ErrInvalidKey = errors.New("lua: invalid table key") + var ErrInvalidLibrary = errors.New("lua: invalid standard library") + var ErrInvalidNativeFunction = errors.New("lua: native function is nil") + var ErrInvalidNextKey = errors.New("lua: invalid key to next") + var ErrInvalidPrototype = errors.New("lua: invalid prototype") + var ErrInvalidUserDataType = errors.New("lua: invalid userdata type descriptor") + var ErrInvalidUserDataTypeName = errors.New("lua: userdata type name is empty") + var ErrInvalidValue = errors.New("lua: invalid value") + var ErrMainThread = errors.New("lua: main thread cannot be resumed") + var ErrNativeCaptureLimit = errors.New("lua: native function capture limit exceeded") + var ErrNegativeCapacity = errors.New("lua: capacity hint is negative") + var ErrNilContext = errors.New("lua: nil context") + var ErrNilReader = errors.New("lua: nil source reader") + var ErrNilScriptFS = errors.New("lua: nil script filesystem") + var ErrNilScriptOpener = errors.New("lua: nil script opener") + var ErrReadOnlyUserData = errors.New("lua: runtime-owned userdata payload is read-only") + var ErrRunning = errors.New("lua: state is executing") + var ErrScriptLoadingDisabled = errors.New("lua: script-file loading is disabled") + var ErrUnsupportedTreeValue = errors.New("lua: unsupported Go value in table tree") + var ErrUserDataTypeConflict = errors.New("lua: userdata type name has a conflicting Go type") + type Error struct + func (err *Error) Category() ErrorCategory + func (err *Error) Error() string + func (err *Error) Traceback() []TraceFrame + func (err *Error) Unwrap() error + func (err *Error) Value() Value + type ErrorCategory uint8 + const ContextError + const ExitError + const LimitError + const ResourceError + const RuntimeError + const SyntaxError + type ExitRequest struct + func (request *ExitRequest) Error() string + func (request *ExitRequest) ExitCode() int + type Frame struct + func (frame Frame) Argument(index int) (Value, bool) + func (frame Frame) ArgumentCount() int + func (frame Frame) Bool(index int) (bool, bool) + func (frame Frame) Call(callable Value, arguments ...Value) ([]Value, error) + func (frame Frame) CallDiscard(callable Value, arguments ...Value) error + func (frame Frame) CallInto(callable Value, arguments []Value, destination []Value) (count int, err error) + func (frame Frame) CallOne(callable Value, arguments ...Value) (Value, error) + func (frame Frame) CoerceNumber(index int) (float64, bool) + func (frame Frame) CoerceString(index int) (string, bool) + func (frame Frame) Collect() error + func (frame Frame) Context() context.Context + func (frame Frame) CurrentThread() *Thread + func (frame Frame) Equal(left, right Value) (bool, error) + func (frame Frame) Function(index int) (*Function, bool) + func (frame Frame) Global(name string) (Value, error) + func (frame Frame) Index(target, key Value) (Value, error) + func (frame Frame) Integer(index int) (int64, bool) + func (frame Frame) IntegerInRange(index int, minimum int64, maximum int64) (int64, bool) + func (frame Frame) IsMissingOrNil(index int) bool + func (frame Frame) Kind(index int) Kind + func (frame Frame) Len(value Value) (Value, error) + func (frame Frame) Number(index int) (float64, bool) + func (frame Frame) Rethrow(failure *Error) + func (frame Frame) Return() Outcome + func (frame Frame) ReturnArguments() Outcome + func (frame Frame) ReturnBool(value bool) Outcome + func (frame Frame) ReturnNil() Outcome + func (frame Frame) ReturnNumber(value float64) Outcome + func (frame Frame) ReturnString(value string) Outcome + func (frame Frame) ReturnValue(value Value) Outcome + func (frame Frame) ReturnValues(values ...Value) Outcome + func (frame Frame) SetGlobal(name string, value Value) error + func (frame Frame) SetIndex(target, key, value Value) error + func (frame Frame) State() *State + func (frame Frame) String(index int) (string, bool) + func (frame Frame) Table(index int) (*Table, bool) + func (frame Frame) Thread(index int) (*Thread, bool) + func (frame Frame) Throw(value Value) + func (frame Frame) ThrowArgError(index int, reason string) + func (frame Frame) ThrowArgTypeError(index int, expected ...Kind) + func (frame Frame) ThrowError(err error) + func (frame Frame) ThrowString(message string) + func (frame Frame) ToString(value Value) (string, error) + func (frame Frame) UserData(index int) (*UserData, bool) + func (frame Frame) Where(level int) string + func (frame Frame) Yield() Outcome + func (frame Frame) YieldArguments() Outcome + func (frame Frame) YieldValue(value Value) Outcome + func (frame Frame) YieldValues(values ...Value) Outcome + type Function hostToken + func (function *Function) Prototype() *Prototype + func (function *Function) Value() Value + type Kind uint8 + const BoolKind + const FunctionKind + const InvalidKind + const NilKind + const NumberKind + const StringKind + const TableKind + const ThreadKind + const UserDataKind + func (kind Kind) String() string + type Library uint8 + const BaseLibrary + const CoroutineLibrary + const DebugLibrary + const IOLibrary + const MathLibrary + const OSLibrary + const PackageLibrary + const StringLibrary + const TableLibrary + type LibrarySet []Library + func CoreLibraries() LibrarySet + func FullLibraries() LibrarySet + type NativeFunc func(Frame) Outcome + type Options struct + Libraries LibrarySet + Location *time.Location + MaxFrames int + MaxHeapBytes int + MaxLoadBytes int + MaxValues int + Now func() time.Time + ScriptLoader ScriptLoader + Stderr io.Writer + Stdin io.Reader + Stdout io.Writer + type Outcome struct + type Prototype struct + func Compile(sourceName, source string) (*Prototype, error) + func (prototype *Prototype) LineRange() (first, last int) + func (prototype *Prototype) SourceName() string + type ResultCapacityError struct + Available int + Required int + func (err *ResultCapacityError) Error() string + func (err *ResultCapacityError) Results() []Value + type ScriptLoader struct + func FSLoader(filesystem fs.FS) ScriptLoader + func FuncLoader(opener ScriptOpener) ScriptLoader + func HostLoader() ScriptLoader + func (loader ScriptLoader) WithPackagePath(path string) ScriptLoader + type ScriptOpener func(ctx context.Context, name string) (io.ReadCloser, error) + type State struct + func New(options Options) (*State, error) + func (state *State) Call(callable Value, arguments ...Value) ([]Value, error) + func (state *State) CallDiscard(callable Value, arguments ...Value) error + func (state *State) CallInto(callable Value, arguments []Value, destination []Value) (count int, err error) + func (state *State) CallOne(callable Value, arguments ...Value) (Value, error) + func (state *State) Close() error + func (state *State) Collect() error + func (state *State) DoFile(path string) ([]Value, error) + func (state *State) DoString(sourceName string, source string) ([]Value, error) + func (state *State) Equal(left, right Value) (bool, error) + func (state *State) FunctionEnvironment(function *Function) (*Table, error) + func (state *State) Global(name string) (Value, error) + func (state *State) HeapBytes() (uint64, error) + func (state *State) Index(target, key Value) (Value, error) + func (state *State) Len(value Value) (Value, error) + func (state *State) Load(sourceName string, reader io.Reader) (*Function, error) + func (state *State) LoadFile(path string) (*Function, error) + func (state *State) LoadPrototype(prototype *Prototype) (*Function, error) + func (state *State) LoadString(sourceName string, source string) (*Function, error) + func (state *State) MainThread() *Thread + func (state *State) Metatable(value Value) (*Table, error) + func (state *State) NewNativeFunction(entry NativeFunc) (*Function, error) + func (state *State) NewTable() (*Table, error) + func (state *State) NewTableFrom(tree any) (*Table, error) + func (state *State) NewTableWithCapacity(arrayHint, recordHint int) (*Table, error) + func (state *State) NewThread(callable Value) (*Thread, error) + func (state *State) NewUserData(payload any) (*UserData, error) + func (state *State) OpenBase() error + func (state *State) OpenCoroutine() error + func (state *State) OpenDebug() error + func (state *State) OpenIO() error + func (state *State) OpenMath() error + func (state *State) OpenOS() error + func (state *State) OpenPackage() error + func (state *State) OpenString() error + func (state *State) OpenTable() error + func (state *State) PreloadModule(name string, loader NativeFunc) error + func (state *State) RawEqual(left, right Value) (bool, error) + func (state *State) RawGlobal(name string) (Value, error) + func (state *State) RawSetGlobal(name string, value Value) error + func (state *State) Registry() (*Table, error) + func (state *State) RemoveContext() error + func (state *State) RestartGC() error + func (state *State) SetContext(ctx context.Context) error + func (state *State) SetFunctionEnvironment(function *Function, environment *Table) error + func (state *State) SetFunctions(table *Table, functions map[string]NativeFunc) error + func (state *State) SetGlobal(name string, value Value) error + func (state *State) SetIndex(target, key, value Value) error + func (state *State) SetMetatable(value Value, metatable *Table) error + func (state *State) StopGC() error + func (state *State) String(text string) Value + func (state *State) ToString(value Value) (string, error) + type Table hostToken + func (table *Table) Next(after Value) (key, value Value, ok bool, err error) + func (table *Table) RawGet(key Value) (Value, error) + func (table *Table) RawGetInt(key int) Value + func (table *Table) RawGetString(key string) Value + func (table *Table) RawLen() int + func (table *Table) RawSet(key, value Value) error + func (table *Table) RawSetInt(key int, value Value) error + func (table *Table) RawSetString(key string, value Value) error + func (table *Table) Value() Value + type Thread hostToken + func (thread *Thread) IsMain() bool + func (thread *Thread) Resume(arguments ...Value) (results []Value, status ThreadStatus, err error) + func (thread *Thread) ResumeInto(arguments []Value, destination []Value) (count int, status ThreadStatus, err error) + func (thread *Thread) State() *State + func (thread *Thread) Status() ThreadStatus + func (thread *Thread) Value() Value + type ThreadStatus uint8 + const ThreadClosed + const ThreadDead + const ThreadNormal + const ThreadReady + const ThreadRunning + const ThreadSuspended + type TraceFrame struct + Function string + Line int + Source string + TailCalls uint32 + func (entry TraceFrame) String() string + type UserData hostToken + func (data *UserData) Data() any + func (data *UserData) SetData(payload any) error + func (data *UserData) Value() Value + type UserDataType struct + func NewUserDataType[T any](state *State, name string) (*UserDataType[T], error) + func (descriptor *UserDataType[T]) FromArgument(frame Frame, index int) (T, bool) + func (descriptor *UserDataType[T]) FromValue(value Value) (T, bool) + func (descriptor *UserDataType[T]) Metatable() *Table + func (descriptor *UserDataType[T]) Name() string + func (descriptor *UserDataType[T]) New(payload T) (*UserData, error) + type Value struct + func Bool(value bool) Value + func Nil() Value + func Number(value float64) Value + func String(text string) Value + func (value Value) AsBool() (bool, bool) + func (value Value) AsFunction() (*Function, bool) + func (value Value) AsNumber() (float64, bool) + func (value Value) AsString() (string, bool) + func (value Value) AsTable() (*Table, bool) + func (value Value) AsThread() (*Thread, bool) + func (value Value) AsUserData() (*UserData, bool) + func (value Value) IsNil() bool + func (value Value) Kind() Kind + func (value Value) SameObject(other Value) (same, applicable bool) + func (value Value) String() string + func (value Value) Truth() bool + func (value Value) Valid() bool