lua

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPlayer

func CheckPlayer(state *lua.State, idx int, gs *gamestate.GameState) (*player.Player, error)

func FileExists

func FileExists(path string) bool

func PushPlayer

func PushPlayer(state *lua.State, p *player.Player)

Types

type CommandManager

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

func NewCommandManager

func NewCommandManager(logger *slog.Logger) *CommandManager

func (*CommandManager) Execute

func (cm *CommandManager) Execute(p *player.Player, cmdName string, args []string) (string, error)

func (*CommandManager) Get

func (cm *CommandManager) Get(name string) *LuaCommand

func (*CommandManager) List

func (cm *CommandManager) List(p *player.Player) []*LuaCommand

func (*CommandManager) LoadCommandFile

func (cm *CommandManager) LoadCommandFile(path string, api *GameAPI) error

func (*CommandManager) LoadCommands

func (cm *CommandManager) LoadCommands(commandsDir string, api *GameAPI) error

func (*CommandManager) Register

func (cm *CommandManager) Register(cmd *LuaCommand)

func (*CommandManager) Reload

func (cm *CommandManager) Reload(commandsDir string, api *GameAPI) error

type CommandPermission

type CommandPermission int
const (
	PermissionNone CommandPermission = iota
	PermissionTrusted
	PermissionGuard
	PermissionModerator
	PermissionAdmin
	PermissionManager
)

type GameAPI

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

func NewGameAPI

func NewGameAPI(gs *gamestate.GameState) *GameAPI

func (*GameAPI) RegisterFunctions

func (api *GameAPI) RegisterFunctions(vm *VM)

func (*GameAPI) SetBanManager

func (api *GameAPI) SetBanManager(bm *bans.Manager)

func (*GameAPI) SetCommandManager

func (api *GameAPI) SetCommandManager(cm *CommandManager)

func (*GameAPI) SetGamemodeVM

func (api *GameAPI) SetGamemodeVM(vm *VM)

func (*GameAPI) SetServer

func (api *GameAPI) SetServer(srv ServerInterface)

type LuaCommand

type LuaCommand struct {
	Name        string
	Aliases     []string
	Permission  CommandPermission
	Description string
	Usage       string
	Handler     string
	VM          *VM
}

type ServerInterface

type ServerInterface interface {
	KickPlayer(playerID uint8, reason string)
	KillPlayer(victimID uint8, killerID uint8, killType protocol.KillType)
	SendChatToAll(message string)
	SendChatToPlayer(p *player.Player, message string)
	SendChatWithType(message string, chatType protocol.ChatType)
	StartVotekick(instigator *player.Player, victimID uint8, reason string) error
	StartVotemap(instigator *player.Player) error
	CastVote(p *player.Player, choice interface{}) error
	CancelVote(p *player.Player) error
	HasActiveVote() bool
	GetActiveVote() vote.Vote
	ReloadCommands() error
	ReloadGamemode() error
	GetConfigPassword(role string) string
	GetCurrentMapName() string
	GetServerName() string
	GetUptime() time.Duration
	RespawnPlayer(playerID uint8)
	SetPlayerTeam(playerID uint8, team uint8)
	RestockPlayer(playerID uint8)
	BroadcastShortPlayerData(p *player.Player)
	DisconnectPlayerWithReason(p *player.Player, reason uint32)
	SendPlayerLeftPacket(playerID uint8)
	SaveMap(filename string) (string, error)
	BroadcastTerritoryCapture(playerID, entityID, winning, state uint8)
	BroadcastProgressBar(entityID, capturingTeam uint8, rate int8, progress float32)
	SendPlayerPositionPacketTo(playerID uint8, pos, ori protocol.Vector3f, toPlayerID uint8)
	SendIntelPositionPacketOnly(objectID uint8, team uint8, position protocol.Vector3f)
	BroadcastCreatePlayer(p *player.Player)
}

type Timer

type Timer struct {
	ID       int
	Callback string
	Interval time.Duration
	Repeat   bool
	NextRun  time.Time
	Args     []interface{}
}

type VM

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

func NewVM

func NewVM() *VM

func (*VM) CallFunction

func (vm *VM) CallFunction(name string, args ...interface{}) error

func (*VM) CallFunctionWithReturn

func (vm *VM) CallFunctionWithReturn(name string, numReturns int, args ...interface{}) ([]interface{}, error)

func (*VM) CancelTimer

func (vm *VM) CancelTimer(id int)

func (*VM) Close

func (vm *VM) Close()

func (*VM) GetGlobalBool

func (vm *VM) GetGlobalBool(name string) (bool, error)

func (*VM) GetGlobalNumber

func (vm *VM) GetGlobalNumber(name string) (float64, error)

func (*VM) GetGlobalString

func (vm *VM) GetGlobalString(name string) (string, error)

func (*VM) GetGlobalTable

func (vm *VM) GetGlobalTable(name string) error

func (*VM) GetTableBool

func (vm *VM) GetTableBool(key string) (bool, error)

func (*VM) GetTableIntArray

func (vm *VM) GetTableIntArray(key string) ([]int, error)

func (*VM) GetTableNumber

func (vm *VM) GetTableNumber(key string) (float64, error)

func (*VM) GetTableString

func (vm *VM) GetTableString(key string) (string, error)

func (*VM) HasFunction

func (vm *VM) HasFunction(name string) bool

func (*VM) LoadFile

func (vm *VM) LoadFile(path string) error

func (*VM) LoadString

func (vm *VM) LoadString(code string) error

func (*VM) PopTable

func (vm *VM) PopTable()

func (*VM) RegisterFunction

func (vm *VM) RegisterFunction(name string, fn lua.Function)

func (*VM) RegisterTimer

func (vm *VM) RegisterTimer(callback string, interval time.Duration, repeat bool, args ...interface{}) int

func (*VM) State

func (vm *VM) State() *lua.State

func (*VM) UpdateTimers

func (vm *VM) UpdateTimers() error

Jump to

Keyboard shortcuts

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