scripting

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventNotFound = errors.New(`event not found`)
)
View Source
var (
	EventFlags = map[string]events.EventFlag{
		`CmdNone`:                    events.CmdNone,
		`CmdSkipScripts`:             events.CmdSkipScripts,
		`CmdSecretly`:                events.CmdSecretly,
		`CmdIsRequeue`:               events.CmdIsRequeue,
		`CmdBlockInput`:              events.CmdBlockInput,
		`CmdUnBlockInput`:            events.CmdUnBlockInput,
		`CmdBlockInputUntilComplete`: events.CmdBlockInputUntilComplete,
	}
)

Functions

func ActorNames

func ActorNames(actorList []*ScriptActor) string

func AddModlueFunction

func AddModlueFunction(namespace string, name string, funcRef any)

func ClearBuffVMs

func ClearBuffVMs()

func ClearItemVMs

func ClearItemVMs()

func ClearMobVMs

func ClearMobVMs()

func ClearRoomVMs

func ClearRoomVMs()

func ClearSpellVMs

func ClearSpellVMs()

func ColorWrap

func ColorWrap(txt string, colorClass ...string) string

func CreateInstancesFromRoomIds

func CreateInstancesFromRoomIds(roomList []int) map[int]int

////////////////////////////////////////////////////////

These functions get exported to the scripting engine

////////////////////////////////////////////////////////

func CreateInstancesFromZone

func CreateInstancesFromZone(zoneName string) map[int]int

func GetMap

func GetMap(mapRoomId int, zoomLevel int, mapHeight int, mapWidth int, mapName string, showSecrets bool, mapMarkers ...string) string

mapRoomId - Room the map is centered on mapSize - wide or normal mapHeight - Height of the map mapWidth - Width of the map mapName - The title of the map showSecrets - Include secret exits/rooms? mapMarkers - A list of strings representing custom map markers:

[roomId],[symbol],[legend text]
1,×,Here

func PruneBuffVMs

func PruneBuffVMs(instanceIds ...int)

func PruneItemVMs

func PruneItemVMs(instanceIds ...int)

func PruneMobVMs

func PruneMobVMs(instanceIds ...int)

func PruneRoomVMs

func PruneRoomVMs(roomIds ...int)

func PruneSpellVMs

func PruneSpellVMs(instanceIds ...int)

func PruneVMs

func PruneVMs(forceClear ...bool)

func RaiseEvent

func RaiseEvent(name string, data map[string]any)

func SendBroadcast

func SendBroadcast(message string)

func SendRoomExitsMessage

func SendRoomExitsMessage(roomId int, message string, isQuiet bool, excludeUserIds ...int)

func SendRoomMessage

func SendRoomMessage(roomId int, message string, excludeIds ...int)

func SendUserMessage

func SendUserMessage(userId int, message string)

func Setup

func Setup(scriptLoadTimeoutMs int, scriptRoomTimeoutMs int)

func TryBuffCommand

func TryBuffCommand(cmd string, rest string, userId int, mobInstanceId int, buffId int) (bool, error)

func TryBuffScriptEvent

func TryBuffScriptEvent(eventName string, userId int, mobInstanceId int, buffId int) (bool, error)

func TryItemCommand

func TryItemCommand(cmd string, item items.Item, userId int) (bool, error)

func TryItemScriptEvent

func TryItemScriptEvent(eventName string, item items.Item, userId int) (bool, error)

func TryMobCommand

func TryMobCommand(cmd string, rest string, mobInstanceId int, sourceId int, sourceType string) (bool, error)

func TryMobScriptEvent

func TryMobScriptEvent(eventName string, mobInstanceId int, sourceId int, sourceType string, details map[string]any) (bool, error)

func TryPlayerDownedEvent

func TryPlayerDownedEvent(mobInstanceId int, downedPlayerId int) (bool, error)

func TryRoomCommand

func TryRoomCommand(cmd string, rest string, userId int) (bool, error)

func TryRoomIdleEvent

func TryRoomIdleEvent(roomId int) (bool, error)

func TryRoomScriptEvent

func TryRoomScriptEvent(eventName string, userId int, roomId int) (bool, error)

func TrySpellScriptEvent

func TrySpellScriptEvent(eventName string, sourceUserId int, sourceMobInstanceId int, spellAggro characters.SpellAggroInfo) (bool, error)

func UtilApplyColorPattern

func UtilApplyColorPattern(input string, patternName string, wordsOnly ...bool) string

func UtilDiceRoll

func UtilDiceRoll(diceQty int, diceSides int) int

func UtilFindMatchIn

func UtilFindMatchIn(search string, items []string) map[string]any

func UtilGetConfig

func UtilGetConfig() configs.Config

func UtilGetMinutesToRounds

func UtilGetMinutesToRounds(minutes int) int

func UtilGetMinutesToTurns

func UtilGetMinutesToTurns(minutes int) int

func UtilGetRoundNumber

func UtilGetRoundNumber() uint64

////////////////////////////////////////////////////////

These functions get exported to the scripting engine

////////////////////////////////////////////////////////

func UtilGetSecondsToRounds

func UtilGetSecondsToRounds(seconds int) int

func UtilGetSecondsToTurns

func UtilGetSecondsToTurns(seconds int) int

func UtilGetTime

func UtilGetTime() gametime.GameDate

func UtilGetTimeString

func UtilGetTimeString() string

func UtilIsDay

func UtilIsDay() bool

func UtilLocateUser

func UtilLocateUser(idOrName any) int

func UtilSetTime

func UtilSetTime(hour int, minutes int)

func UtilSetTimeDay

func UtilSetTimeDay()

func UtilSetTimeNight

func UtilSetTimeNight()

func UtilStripPrepositions

func UtilStripPrepositions(input string) string

Types

type ScriptActor

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

func GetActor

func GetActor(userId int, mobInstanceId int) *ScriptActor

////////////////////////////////////////////////////////

These functions get exported to the scripting engine

////////////////////////////////////////////////////////

func GetMob

func GetMob(mobInstanceId int) *ScriptActor

func GetUser

func GetUser(userId int) *ScriptActor

func (ScriptActor) AddEventLog

func (a ScriptActor) AddEventLog(category string, message string)

func (ScriptActor) AddGold

func (a ScriptActor) AddGold(amt int, bankAmt ...int)

func (ScriptActor) AddHealth

func (a ScriptActor) AddHealth(amt int) int

func (ScriptActor) AddMana

func (a ScriptActor) AddMana(amt int) int

func (ScriptActor) CancelBuffWithFlag

func (a ScriptActor) CancelBuffWithFlag(buffFlag string) bool

func (ScriptActor) ChangeAlignment

func (a ScriptActor) ChangeAlignment(alignmentChange int)

func (ScriptActor) CharmExpire

func (a ScriptActor) CharmExpire()

func (ScriptActor) CharmRemove

func (a ScriptActor) CharmRemove()

func (ScriptActor) CharmSet

func (a ScriptActor) CharmSet(userId int, charmRounds int, onRevertCommand ...string)

func (ScriptActor) Command

func (a ScriptActor) Command(cmd string, waitSeconds ...float64)

func (ScriptActor) CommandFlagged

func (a ScriptActor) CommandFlagged(cmd string, flags events.EventFlag, waitSeconds ...float64)

func (ScriptActor) GetAlignment

func (a ScriptActor) GetAlignment() int

func (ScriptActor) GetAlignmentName

func (a ScriptActor) GetAlignmentName() string

func (ScriptActor) GetBackpackItems

func (a ScriptActor) GetBackpackItems() []ScriptItem

func (ScriptActor) GetChanceToTame

func (a ScriptActor) GetChanceToTame(target ScriptActor) int

func (ScriptActor) GetCharacterName

func (a ScriptActor) GetCharacterName(wrapInTags bool) string

func (ScriptActor) GetCharmCount

func (a ScriptActor) GetCharmCount() int

func (ScriptActor) GetCharmedUserId

func (a ScriptActor) GetCharmedUserId() int

func (ScriptActor) GetHealth

func (a ScriptActor) GetHealth() int

func (ScriptActor) GetHealthMax

func (a ScriptActor) GetHealthMax() int

func (ScriptActor) GetHealthPct

func (a ScriptActor) GetHealthPct() float64

func (ScriptActor) GetLastInputRound

func (a ScriptActor) GetLastInputRound() uint64

func (ScriptActor) GetLevel

func (a ScriptActor) GetLevel() int

func (ScriptActor) GetMana

func (a ScriptActor) GetMana() int

func (ScriptActor) GetManaMax

func (a ScriptActor) GetManaMax() int

func (ScriptActor) GetManaPct

func (a ScriptActor) GetManaPct() float64

func (ScriptActor) GetMaxCharmCount

func (a ScriptActor) GetMaxCharmCount() int

func (ScriptActor) GetMiscCharacterData

func (a ScriptActor) GetMiscCharacterData(key string) any

func (ScriptActor) GetMiscCharacterDataKeys

func (a ScriptActor) GetMiscCharacterDataKeys(prefixMatches ...string) []string

func (ScriptActor) GetMobKills

func (a ScriptActor) GetMobKills(mobId int) int

func (ScriptActor) GetPartyMembers

func (a ScriptActor) GetPartyMembers() []ScriptActor

func (ScriptActor) GetPet

func (a ScriptActor) GetPet() *pets.Pet

func (ScriptActor) GetRace

func (a ScriptActor) GetRace() string

func (ScriptActor) GetRaceKills

func (a ScriptActor) GetRaceKills(race string) int

func (ScriptActor) GetRoomId

func (a ScriptActor) GetRoomId() int

func (ScriptActor) GetSize

func (a ScriptActor) GetSize() string

func (ScriptActor) GetSkillLevel

func (a ScriptActor) GetSkillLevel(skillName string) int

func (ScriptActor) GetStat

func (a ScriptActor) GetStat(statName string) int

func (ScriptActor) GetStatMod

func (a ScriptActor) GetStatMod(statModName string) int

func (ScriptActor) GetStatPoints

func (a ScriptActor) GetStatPoints() int

func (ScriptActor) GetTameMastery

func (a ScriptActor) GetTameMastery() map[int]int

func (ScriptActor) GetTempData

func (a ScriptActor) GetTempData(key string) any

func (ScriptActor) GetTrainingPoints

func (a ScriptActor) GetTrainingPoints() int

func (ScriptActor) GiveBuff

func (a ScriptActor) GiveBuff(buffId int, source string)

func (ScriptActor) GiveExtraLife

func (a ScriptActor) GiveExtraLife()

func (ScriptActor) GiveItem

func (a ScriptActor) GiveItem(itm any)

func (ScriptActor) GiveQuest

func (a ScriptActor) GiveQuest(questId string)

func (ScriptActor) GiveStatPoints

func (a ScriptActor) GiveStatPoints(ct int)

func (ScriptActor) GiveTrainingPoints

func (a ScriptActor) GiveTrainingPoints(ct int)

func (ScriptActor) GrantXP

func (a ScriptActor) GrantXP(xpAmt int, reason string)

func (ScriptActor) HasBuff

func (a ScriptActor) HasBuff(buffId int) bool

func (ScriptActor) HasBuffFlag

func (a ScriptActor) HasBuffFlag(buffFlag string) bool

func (ScriptActor) HasItemId

func (a ScriptActor) HasItemId(itemId int, excludeWorn ...bool) bool

func (ScriptActor) HasQuest

func (a ScriptActor) HasQuest(questId string) bool

func (ScriptActor) HasSpell

func (a ScriptActor) HasSpell(spellId string) bool

func (ScriptActor) InstanceId

func (a ScriptActor) InstanceId() int

func (ScriptActor) IsAggro

func (a ScriptActor) IsAggro(actor ScriptActor) bool

func (ScriptActor) IsCharmed

func (a ScriptActor) IsCharmed(userId ...int) bool

Returns true if a mob is charmed by/friendly to a player. If userId is ommitted, it will return true if the mob is charmed by any player.

func (ScriptActor) IsHome

func (a ScriptActor) IsHome() bool

func (ScriptActor) IsTameable

func (a ScriptActor) IsTameable() bool

func (ScriptActor) LearnSpell

func (a ScriptActor) LearnSpell(spellId string) bool

func (ScriptActor) MobTypeId

func (a ScriptActor) MobTypeId() int

func (ScriptActor) MoveRoom

func (a ScriptActor) MoveRoom(destRoomId int, leaveCharmedMobs ...bool)

func (ScriptActor) Pathing

func (a ScriptActor) Pathing() bool

func (ScriptActor) PathingAtWaypoint

func (a ScriptActor) PathingAtWaypoint() bool

func (ScriptActor) RemoveBuff

func (a ScriptActor) RemoveBuff(buffId int) bool

Remove a buff silently

func (ScriptActor) SendText

func (a ScriptActor) SendText(msg string)

func (ScriptActor) SetAdjective

func (a ScriptActor) SetAdjective(adj string, addIt bool)

func (ScriptActor) SetCharacterName

func (a ScriptActor) SetCharacterName(newName string)

func (ScriptActor) SetHealth

func (a ScriptActor) SetHealth(amt int)

func (ScriptActor) SetMiscCharacterData

func (a ScriptActor) SetMiscCharacterData(key string, value any)

func (ScriptActor) SetTameMastery

func (a ScriptActor) SetTameMastery(mobId int, newSkillLevel int)

func (ScriptActor) SetTempData

func (a ScriptActor) SetTempData(key string, value any)

func (ScriptActor) ShorthandId

func (a ScriptActor) ShorthandId() string

func (ScriptActor) Sleep

func (a ScriptActor) Sleep(seconds int)

func (ScriptActor) TakeItem

func (a ScriptActor) TakeItem(itm ScriptItem)

func (ScriptActor) TimerExists

func (a ScriptActor) TimerExists(name string) bool

func (ScriptActor) TimerExpired

func (a ScriptActor) TimerExpired(name string) bool

func (ScriptActor) TimerSet

func (a ScriptActor) TimerSet(name string, period string)

func (ScriptActor) TrainSkill

func (a ScriptActor) TrainSkill(skillName string, skillLevel int) bool

func (ScriptActor) Uncurse

func (a ScriptActor) Uncurse() []*ScriptItem

func (ScriptActor) UpdateItem

func (a ScriptActor) UpdateItem(itm ScriptItem)

func (ScriptActor) UserId

func (a ScriptActor) UserId() int

type ScriptItem

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

func CreateItem

func CreateItem(itemId int) *ScriptItem

CreateItem creates a NEW instance of an item by id

func GetItem

func GetItem(i items.Item) *ScriptItem

Converts an item into a ScriptItem for use in the scripting engine

func (ScriptItem) AddUsesLeft

func (i ScriptItem) AddUsesLeft(amount int) int

func (ScriptItem) GetLastUsedRound

func (i ScriptItem) GetLastUsedRound() uint64

func (ScriptItem) GetTempData

func (i ScriptItem) GetTempData(key string) any

func (ScriptItem) GetUsesLeft

func (i ScriptItem) GetUsesLeft() int

func (ScriptItem) ItemId

func (i ScriptItem) ItemId() int

func (ScriptItem) MarkLastUsed

func (i ScriptItem) MarkLastUsed(clear ...bool) uint64

func (ScriptItem) Name

func (i ScriptItem) Name(simpleVersion ...bool) string

func (ScriptItem) NameComplex

func (i ScriptItem) NameComplex() string

func (ScriptItem) NameSimple

func (i ScriptItem) NameSimple() string

func (ScriptItem) Redescribe

func (i ScriptItem) Redescribe(newDescription string)

func (ScriptItem) Rename

func (i ScriptItem) Rename(newName string, displayNameOrStyle ...string)

func (ScriptItem) SetTempData

func (i ScriptItem) SetTempData(key string, value any)

func (ScriptItem) SetUsesLeft

func (i ScriptItem) SetUsesLeft(amount int) int

func (ScriptItem) ShorthandId

func (i ScriptItem) ShorthandId() string

type ScriptRoom

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

func GetRoom

func GetRoom(roomId int) *ScriptRoom

func (ScriptRoom) AddMutator

func (r ScriptRoom) AddMutator(mutName string)

func (ScriptRoom) AddTemporaryExit

func (r ScriptRoom) AddTemporaryExit(exitNameSimple string, exitNameFancy string, exitRoomId int, expiresTimeString string) bool

func (ScriptRoom) DestroyItem

func (r ScriptRoom) DestroyItem(itm ScriptItem)

func (ScriptRoom) GetAllActors

func (r ScriptRoom) GetAllActors() []*ScriptActor

func (ScriptRoom) GetContainers

func (r ScriptRoom) GetContainers() []string

func (ScriptRoom) GetExits

func (r ScriptRoom) GetExits() []map[string]any

func (ScriptRoom) GetItems

func (r ScriptRoom) GetItems() []ScriptItem

func (ScriptRoom) GetMob

func (r ScriptRoom) GetMob(mobId int, createIfMissing ...bool) *ScriptActor

Get the first mob of the MobId type provided.

func (ScriptRoom) GetMobs

func (r ScriptRoom) GetMobs(mobId ...int) []*ScriptActor

Optionally can provide a MobId to look for

func (ScriptRoom) GetPermData

func (r ScriptRoom) GetPermData(key string) any

func (ScriptRoom) GetPlayers

func (r ScriptRoom) GetPlayers() []*ScriptActor

func (ScriptRoom) GetTempData

func (r ScriptRoom) GetTempData(key string) any

func (ScriptRoom) HasMutator

func (r ScriptRoom) HasMutator(mutName string) bool

func (ScriptRoom) HasQuest

func (r ScriptRoom) HasQuest(questId string, partyUserId ...int) []int

Returns a list of userIds found to have the questId if userIdParty is specified, will only check users in the party of the user.

func (ScriptRoom) IsEphemeral

func (r ScriptRoom) IsEphemeral() bool

func (ScriptRoom) IsLocked

func (r ScriptRoom) IsLocked(exitName string) bool

func (ScriptRoom) MissingQuest

func (r ScriptRoom) MissingQuest(questId string, partyUserId ...int) []int

Returns a list of userIds found to NOT have the questId if userIdParty is specified, will only check users in the party of the user.

func (ScriptRoom) RemoveMutator

func (r ScriptRoom) RemoveMutator(mutName string)

func (ScriptRoom) RemoveTemporaryExit

func (r ScriptRoom) RemoveTemporaryExit(exitNameSimple string, exitNameFancy string, exitRoomId int) bool

func (ScriptRoom) RepeatSpawnItem

func (r ScriptRoom) RepeatSpawnItem(itemId int, roundFrequency int, containerName ...string) bool

func (ScriptRoom) RoomId

func (r ScriptRoom) RoomId() int

func (ScriptRoom) RoomIdSource

func (r ScriptRoom) RoomIdSource() int

func (ScriptRoom) SendText

func (r ScriptRoom) SendText(msg string, excludeIds ...int)

func (ScriptRoom) SendTextToExits

func (r ScriptRoom) SendTextToExits(msg string, isQuiet bool, excludeUserIds ...int)

func (ScriptRoom) SetLocked

func (r ScriptRoom) SetLocked(exitName string, lockIt bool)

func (ScriptRoom) SetPermData

func (r ScriptRoom) SetPermData(key string, value any)

func (ScriptRoom) SetTempData

func (r ScriptRoom) SetTempData(key string, value any)

func (ScriptRoom) SpawnItem

func (r ScriptRoom) SpawnItem(itemId int, inStash bool)

func (ScriptRoom) SpawnMob

func (r ScriptRoom) SpawnMob(mobId int) *ScriptActor

type TextWrapperStyle

type TextWrapperStyle struct {
	Fg           string // ansi class name for foreground
	Bg           string // ansi class name for background
	ColorPattern string // optional color pattern
	// contains filtered or unexported fields
}

func (*TextWrapperStyle) AnsiClass

func (t *TextWrapperStyle) AnsiClass() string

func (*TextWrapperStyle) Empty

func (t *TextWrapperStyle) Empty() bool

func (*TextWrapperStyle) Reset

func (t *TextWrapperStyle) Reset()

func (*TextWrapperStyle) Set

func (t *TextWrapperStyle) Set(fg string, bg string, colorpattern string, colorStyle ...colorpatterns.ColorizeStyle)

func (*TextWrapperStyle) Wrap

func (t *TextWrapperStyle) Wrap(str string) string

type VMWrapper

type VMWrapper struct {
	VM *goja.Runtime
	// contains filtered or unexported fields
}

func (*VMWrapper) GetFunction

func (vmw *VMWrapper) GetFunction(name string) (goja.Callable, bool)

Jump to

Keyboard shortcuts

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