scripting

package
v0.0.0-...-d78e010 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Export module registration functions for packages that might use them directly
	RegisterNetworkModule = modules.RegisterNetworkModule
	RegisterHTTPModule    = modules.RegisterHTTPModule
	RegisterCryptoModule  = modules.RegisterCryptoModule
	RegisterSystemModule  = modules.RegisterSystemModule
	RegisterFileModule    = modules.RegisterFileModule
	RegisterTimeModule    = modules.RegisterTimeModule
	RegisterUIModule      = modules.RegisterUIModule
	RegisterJSONModule    = modules.RegisterJSONModule
)

Compatibility exports for backward compatibility

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxExecutionTime time.Duration
	MaxMemory        int64
	RestrictedMode   bool
	AllowedHosts     []string
	DeniedHosts      []string
	ModulesPath      string
	Debug            bool
}

Config holds configuration for the Lua engine

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

type Engine

type Engine struct {
	L *lua.LState
	// contains filtered or unexported fields
}

Engine represents a Lua scripting engine for GoCat

func NewEngine

func NewEngine(config *Config) *Engine

NewEngine creates a new Lua engine with configuration

func (*Engine) Close

func (e *Engine) Close()

Close closes the Lua engine and releases resources

func (*Engine) ExecuteFunction

func (e *Engine) ExecuteFunction(functionName string, args ...lua.LValue) ([]lua.LValue, error)

ExecuteFunction executes a specific function in the loaded script

func (*Engine) ExecuteScript

func (e *Engine) ExecuteScript(scriptName string) error

ExecuteScript executes a loaded script's main function

func (*Engine) GetGlobal

func (e *Engine) GetGlobal(name string) lua.LValue

GetGlobal gets a global variable from Lua state

func (*Engine) IsRestricted

func (e *Engine) IsRestricted() bool

IsRestricted returns whether the engine is in restricted mode

func (*Engine) LoadScript

func (e *Engine) LoadScript(scriptPath string) error

LoadScript loads a Lua script from file

func (*Engine) LoadString

func (e *Engine) LoadString(code string) error

LoadString loads and executes Lua code from a string

func (*Engine) SetArgs

func (e *Engine) SetArgs(args []string)

SetArgs sets command line arguments for the script

func (*Engine) SetDebug

func (e *Engine) SetDebug(debug bool)

SetDebug enables or disables debug mode

func (*Engine) SetGlobal

func (e *Engine) SetGlobal(name string, value lua.LValue)

SetGlobal sets a global variable in Lua state

type EngineConfig

type EngineConfig = Config

EngineConfig is a compatibility alias DEPRECATED: Use Config instead

type LuaEngine

type LuaEngine struct {
	*Engine
}

LuaEngine is a compatibility wrapper for the old API DEPRECATED: Use Engine instead

func NewLuaEngine

func NewLuaEngine(config *EngineConfig) *LuaEngine

NewLuaEngine creates a new Lua engine (compatibility function) DEPRECATED: Use NewEngine instead

func (*LuaEngine) ExecuteScript

func (e *LuaEngine) ExecuteScript(scriptName string) error

ExecuteScript executes a loaded script's main function DEPRECATED: Use ExecuteFunction("main") instead

func (*LuaEngine) GetLuaState

func (e *LuaEngine) GetLuaState() *lua.LState

GetLuaState returns the underlying Lua state This is for advanced users who need direct access

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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