usercommands

package
v0.0.0-...-bbe6cbb Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: GPL-3.0 Imports: 41 Imported by: 0

README

usercommands

The usercommands package defines a function type and contains all of the commands a user can enter.

type UserCommand func(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

All commands follow that definition, where

  • rest contains everything except the initial command the user entered (if user entered glarble some text, rest would contain some text)
  • user is the user object executing the command
  • room is the room object for the room the user is in while executing the command

func Glarble(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) {
    
    room.SendText(`This glarble text goes out to all players in room`)

    room.SendText(`This glarble text goes out to all players in room except the user who typed the command`, user.UserId)

    user.SendText(`This glarble text goes out to the user`)

    // we handled this command in this function, so return true
    return true, nil
}

Then the command must be entered into the userCommands map in usercommands.go

Each entry into userCommands defines:

  • UserCommand - the function for the command
  • AllowedWhenDowned - can users execute this command when downed?
  • AdminOnly - is this a command only admins can use?

Must return two values:

  • bool - whether this was handled or should be allowed to continue down processing chain (and indicate a failed command if never gets handled)
  • error - An error with error message (for logging purposes)

TODO: More info.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFunctionExporter

func AddFunctionExporter(f FunctionExporter)

func Aid

func Aid(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Protection Skill Level 1 - Aid (revive) a player Level 3 - Aid (revive) a player, even during combat

func Alias

func Alias(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Appraise

func Appraise(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Ask

func Ask(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Attack

func Attack(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Backstab

func Backstab(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

SkullDuggery Skill Level 2 - Backstab

func BadCommands

func BadCommands(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * badcommands (All)

func Bank

func Bank(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Biome

func Biome(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Break

func Break(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Broadcast

func Broadcast(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Global chat room

func Buff

func Buff(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * buff (All)

func Build

func Build(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * build (All)

func Bump

func Bump(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

SkullDuggery Skill Level 3 - Backstab

func Bury

func Bury(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Buy

func Buy(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Cast

func Cast(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Cast Skill Level 1 - You can cast spells Level 2 - Become proficient in a spell at 125% rate Level 3 - Become proficient in a spell at 175% rate Level 4 - Become proficient in a spell at 250% rate

func Character

func Character(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Command

func Command(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * command (All)

func Conditions

func Conditions(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Consider

func Consider(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Cooldowns

func Cooldowns(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Deafen

func Deafen(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * deafen (All)

func Default

func Default(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Default is a special command that tries to contextually pick a default action for a room. The failover is to "look"

func Disarm

func Disarm(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Brawling Skill Level 4 - Attempt to disarm an opponent.

func Drink

func Drink(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Drop

func Drop(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func DualWield

func DualWield(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Dual WIeld Level 1 - You can dual wield weapons that you normally couldn't. Attacks use a random weapon. Level 2 - Occasionaly you will attack with both weapons in one round. Level 3 - You will always attack with both weapons when Dual wielding. Level 4 - Dual wielding incurs fewer penalties

func Eat

func Eat(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Emote

func Emote(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Enchant

func Enchant(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Enchant Skill Level 1 - Enchant a weapon with a damage bonus. Level 2 - Enchant equipment with a defensive bonus. Level 3 - Add a stat bonus to a weapon or equipment in addition to the above. Level 4 - Remove the enchantment or curse from any object.

func Equip

func Equip(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Exits

func Exits(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Experience

func Experience(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Flee

func Flee(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Gearup

func Gearup(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Get

func Get(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func GetCmdSuggestions

func GetCmdSuggestions(text string, includeAdmin bool) []string

Returns a list of close match commands

func GetExportedFunction

func GetExportedFunction(fName string) (any, bool)

func GetHelpSuggestions

func GetHelpSuggestions(text string, includeAdmin bool) []string

func GetLockRender

func GetLockRender(sequence string, entered string, viewingUserId int) string

func Give

func Give(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Go

func Go(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Grant

func Grant(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * grant (All)

func Help

func Help(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func History

func History(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Inbox

func Inbox(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Inspect

func Inspect(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Peep Skill Level 1 - Reveals the type and value of items. Level 2 - Reveals weapon damage or uses an item has left. Level 3 - Reveals any stat modifiers an item has. Level 4 - Reveals special magical properties like elemental effects.

func Inventory

func Inventory(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Item

func Item(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * item (All) * item.create (Create a new item) * item.spawn (Spawn a new item in the room)

func Jobs

func Jobs(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func KeyRing

func KeyRing(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Killstats

func Killstats(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func List

func List(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Locate

func Locate(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * locate (All)

func Lock

func Lock(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Look

func Look(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Macros

func Macros(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Map

func Map(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Skill Map Level 1 - Map a 5x5 area Level 2 - Map a 9x7 area Level 3 - Map a 13x9 area Level 4 - Map a 17x9 area, and enables the "wide" version.

func Mob

func Mob(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * mob (All) * mob.create (Create new mobs) * mob.spawn (Spawn a mob in the room)

func Modify

func Modify(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * modify (All) * modify.role (Change user roles)

func Motd

func Motd(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Mudmail

func Mudmail(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * mudmail (All)

func Mute

func Mute(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * mute (All)

func Noop

func Noop(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

This is a no-op, does nothing

func Offer

func Offer(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Online

func Online(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Party

func Party(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Password

func Password(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Paz

func Paz(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * paz (All)

func Peep

func Peep(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Peep Skill Level 1 - Always visibly see the health % of an NPC Level 2 - Reveals detailed stats of a player or mob. Level 3 - Reveals detailed stats of the player or mob, plus equipment and items Level 4 - eveals detailed stats of the player or mob, plus equipment and items, and tells you the % chance of dropping items.

func Pet

func Pet(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Picklock

func Picklock(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Pickpocket

func Pickpocket(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

SkullDuggery Skill Level 4 - Pickpocket

func Portal

func Portal(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Portal Skill Level 1 - Teleport back to town square Level 2 - Teleport back to the root of the area you are in Level 3 - Set a new destination for your portal teleportation Level 4 - Create a physical portal that you can share with players, or return through.

func Pray

func Pray(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Protection Skill Level 4 - Pray to gods for a blessing

func Prepare

func Prepare(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * prepare (All)

func Print

func Print(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Prints message to screen

func PrintLine

func PrintLine(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

PrintLine (command `printline`) is just a simple measuring tool/ruler for layout purposes

func Put

func Put(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Pvp

func Pvp(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func QuestToken

func QuestToken(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * questtoken (All)

func Quests

func Quests(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Quit

func Quit(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Rank

func Rank(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Protection Skill Level 2 - Front/Backrank

func Read

func Read(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Recover

func Recover(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Brawling Skill Level 1 - Enter a state of rest where health is recovered more quickly

func Redescribe

func Redescribe(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * redescribe (All)

func RegisterCommand

func RegisterCommand(command string, handlerFunc UserCommand, disabledWhenDowned bool, isAdminOnly bool)

Register mob commands from outside of the package

func Reload

func Reload(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * reload (All)

func Remove

func Remove(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Rename

func Rename(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * rename (All)

func Room

func Room(rest string, user *users.UserRecord, liveRoom *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * room (All) * room.edit (All edit commands) * room.edit.container (Edit containers) * room.edit.exits (Edit exits) * room.edit.mutators (Edit mutators) * room.edit.nouns (Edit nouns) * room.copy (Copy room properties from one room to another) * room.info (See a room summary) * room.set (Set properties of the room)

func Save

func Save(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Say

func Say(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Scribe

func Scribe(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Scribe Skill Level 1 - Scribe to a scrap of paper Level 2 - Scribe to a sign Level 3 - Scribe a hidden rune Level 4 - TODO

func Search(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Searcg Skill Level 1 - Find secret exits or hidden players/mobs Level 2 - Find objects stashed in the area Level 3 - ??? Level 4 - You are always aware of hidden players/mobs in the area

(Lvl 1) <ansi fg="skill">search</ansi> Search for secret exits or hidden players/mobs. (Lvl 2) <ansi fg="skill">search</ansi> Finds objects that may be hidden in the area. (Lvl 3) <ansi fg="skill">search</ansi> Finds special/unknown "things of interest" in the area. (Lvl 4) <ansi fg="skill">search</ansi> Doubles your chance of success when searching.

func Sell

func Sell(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Server

func Server(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * server (All)

func Set

func Set(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Share

func Share(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Shoot

func Shoot(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Shout

func Shout(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Show

func Show(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Skills

func Skills(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Skillset

func Skillset(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * skillset (All)

func Sneak

func Sneak(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

SkullDuggery Skill Level 1 - Sneak

func Spawn

func Spawn(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * spawn (All)

func Spell

func Spell(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * spell (All) * spell.create (Create new spells) * spell.list (List all spells)

func Spells

func Spells(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Start

func Start(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Stash

func Stash(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Status

func Status(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Storage

func Storage(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Suicide

func Suicide(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func SysLogs

func SysLogs(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * syslogs (All)

func Tackle

func Tackle(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Brawling Skill Level 3 - Attempt to tackle an opponent, making them miss a round.

func Tame

func Tame(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Skill Tame Level 1 - Tame up to 2 creatures Level 2 - Tame up to 3 creatures Level 3 - Tame up to 4 creatures Level 4 - Tame up to 5 creatures

func Teleport

func Teleport(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * teleport (All) * teleport.direction (Teleport through walls in a direction) * teleport.playername (Teleport to a player name) * teleport.roomid (Teleport to a roomId)

func Throw

func Throw(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Brawling Skill Level 2 - You can throw objects at NPCs or other rooms.

func Track

func Track(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Skill Track Level 1 - Display the last player or mob to walk through here (not the currently player or current mobs) Level 2 - Display all players and mobs to recently walk through here Level 3 - Shows exit information for all tracked players or mobs Level 4 - Specify a mob or username and every room you enter will tell you what exit they took.

func Train

func Train(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Trash

func Trash(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func TryCommand

func TryCommand(cmd string, rest string, userId int, flags events.EventFlag) (bool, error)

func TryRoomScripts

func TryRoomScripts(input, alias, rest string, userId int) (bool, error)

TryRoomScripts is called to try both the onCommand_X direct route and also onCommand with a 'cmd' parameter. Returns true if a script handled it. False if not.

func UnDeafen

func UnDeafen(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func UnMute

func UnMute(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Uncurse

func Uncurse(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Unenchant

func Unenchant(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Unlock

func Unlock(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Use

func Use(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Whisper

func Whisper(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Who

func Who(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

func Zap

func Zap(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * zap (All)

func ZombieAct

func ZombieAct(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Later this can be used for zombie specific decision making, such as when players intentionally zombify and let "ai" take over

func Zone

func Zone(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

* Role Permissions: * zone (All)

Types

type CommandAccess

type CommandAccess struct {
	Func              UserCommand
	AllowedWhenDowned bool
	AdminOnly         bool
}

type CommandHelpItem

type CommandHelpItem struct {
	Command   string
	Type      string // command/skill
	Category  string
	AdminOnly bool
}

type FunctionExporter

type FunctionExporter interface {
	GetExportedFunction(funcName string) (any, bool)
}

type SkillsOptions

type SkillsOptions struct {
	SkillList      map[string]int
	TrainingPoints int
	SkillCooldowns map[string]int
}

type TrainingOption

type TrainingOption struct {
	Name          string
	CurrentStatus string
	Cost          int
	Message       string
}

type TrainingOptions

type TrainingOptions struct {
	TrainingPoints int
	Options        []TrainingOption
}

type UserCommand

type UserCommand func(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error)

Signature of user command

Source Files

Jump to

Keyboard shortcuts

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