Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions _datafiles/guides/building/scripting/FUNCTIONS_ACTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ ActorObjects are the basic object that represents Users and NPCs
- [ActorObject.AddGold(amt int \[, bankAmt int\])](#actorobjectaddgoldamt-int--bankamt-int)
- [ActorObject.AddHealth(amt int) int](#actorobjectaddhealthamt-int-int)
- [ActorObject.Sleep(seconds int)](#actorobjectsleepseconds-int)
- [ActorObject.Command(cmd string, waitTurns ...int)](#actorobjectcommandcmd-string-waitturns-int)
- [ActorObject.Command(cmd string \[, waitTurns int\])](#actorobjectcommandcmd-string--waitturns-int)
- [ActorObject.CommandFlagged(cmd string, flag int \[, waitTurns int\])](#actorobjectcommandflaggedcmd-string-flag-int--waitturns-int)
- [ActorObject.IsTameable() bool](#actorobjectistameable-bool)
- [ActorObject.TrainSkill(skillName string, skillLevel int)](#actorobjecttrainskillskillname-string-skilllevel-int)
- [ActorObject.GetSkillLevel(skillName string)](#actorobjectgetskilllevelskillname-string)
Expand Down Expand Up @@ -259,7 +260,7 @@ _Note: Only works on mobs._
| --- | --- |
| seconds | How many seconds to wait. |

## [ActorObject.Command(cmd string, waitTurns ...int)](/internal/scripting/actor_func.go)
## [ActorObject.Command(cmd string [, waitTurns int])](/internal/scripting/actor_func.go)
Forces an ActorObject to execute a command as if they entered it

_Note: Don't underestimate the power of this function! Complex and interesting behaviors or interactions can emerge from using it._
Expand All @@ -269,6 +270,18 @@ _Note: Don't underestimate the power of this function! Complex and interesting b
| cmd | The command to execute such as `look west` or `say goodbye`. |
| waitTurns (optional) | The number of turns (NOT rounds) to wait before executing the command. |

## [ActorObject.CommandFlagged(cmd string, flag int [, waitTurns int])](/internal/scripting/actor_func.go)
Forces an ActorObject to execute a command as if they entered it.
WARNING: Advanced Usage. Required a flag integer.

_Note: Don't underestimate the power of this function! Complex and interesting behaviors or interactions can emerge from using it._

| Argument | Explanation |
| --- | --- |
| cmd | The command to execute such as `look west` or `say goodbye`. |
| flag | The special control flag to pass to the command. |
| waitTurns (optional) | The number of turns (NOT rounds) to wait before executing the command. |

## [ActorObject.IsTameable() bool](/internal/scripting/actor_func.go)
Returns `true` if actor can be tamed.

Expand Down
6 changes: 3 additions & 3 deletions _datafiles/world/default/users/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ character:
- buffid: 28
onstartevent: true
permabuff: true
roundcounter: 28
roundcounter: 23
triggersleft: 1000000000
- buffid: 29
onstartevent: true
permabuff: true
roundcounter: 36
roundcounter: 16
triggersleft: 1000000000
- buffid: 39
onstartevent: false
permabuff: true
roundcounter: 10
roundcounter: 5
triggersleft: 1000000000
equipment:
weapon:
Expand Down
1 change: 1 addition & 0 deletions internal/events/eventtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Input struct {
MobInstanceId int
InputText string
WaitTurns int
Flags uint64
}

func (i Input) Type() string { return `Input` }
Expand Down
1 change: 1 addition & 0 deletions internal/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type RoomExit struct {
RoomId int
Secret bool `yaml:"secret,omitempty"`
MapDirection string `yaml:"mapdirection,omitempty"` // Optionaly indicate the direction of this exit for mapping purposes
ExitMessage string `yaml:"exitmessage,omitempty"` // If set, this message is sent to the user, followed by a delay, before they actually go through the exit.
Lock gamelock.Lock `yaml:"lock,omitempty"` // 0 - no lock. greater than zero = difficulty to unlock.
}

Expand Down
11 changes: 11 additions & 0 deletions internal/scripting/actor_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ func (a ScriptActor) Command(cmd string, waitTurns ...int) {
}
}

func (a ScriptActor) CommandFlagged(cmd string, flags int, waitTurns ...int) {
if len(waitTurns) < 1 {
waitTurns = append(waitTurns, 0)
}
if a.userId > 0 {
a.userRecord.CommandFlagged(cmd, uint64(flags), waitTurns[0])
} else {
a.mobRecord.Command(cmd, waitTurns[0])
}
}

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

if a.userRecord == nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/usercommands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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) (bool, error)
type UserCommand func(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error)
```

All commands follow that definition, where
Expand All @@ -13,7 +13,7 @@ All commands follow that definition, where

```

func Glarble(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func Glarble(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

room.SendText(`This glarble text goes out to all players in room`)

Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.badcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "clear" {
badinputtracker.Clear()
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.buff.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

// args should look like one of the following:
// target buffId - put buff on target if in the room
Expand Down
4 changes: 2 additions & 2 deletions internal/usercommands/admin.build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/volte6/gomud/internal/util"
)

func IBuild(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func IBuild(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

// args should look like one of the following:
// info <optional room id>
Expand Down Expand Up @@ -115,7 +115,7 @@ func IBuild(rest string, user *users.UserRecord, room *rooms.Room) (bool, error)
return true, nil
}

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

// args should look like one of the following:
// info <optional room id>
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.command.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

// args should look like one of the following:
// target buffId - put buff on target if in the room
Expand Down
4 changes: 2 additions & 2 deletions internal/usercommands/admin.deafen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.deafen", nil)
Expand All @@ -36,7 +36,7 @@ func Deafen(rest string, user *users.UserRecord, room *rooms.Room) (bool, error)
return true, nil
}

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.deafen", nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.grant", nil)
Expand Down
14 changes: 7 additions & 7 deletions internal/usercommands/admin.item.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if user.Permission != users.PermissionAdmin {
user.SendText(`<ansi fg="alert-4">Only admins can use this command</ansi>`)
Expand All @@ -33,23 +33,23 @@ func Item(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {

// create a new item
if args[0] == `create` {
return item_Create(strings.TrimSpace(rest[6:]), user, room)
return item_Create(strings.TrimSpace(rest[6:]), user, room, flags)
}

// spawn an existing item
if args[0] == `spawn` {
return item_Spawn(strings.TrimSpace(rest[5:]), user, room)
return item_Spawn(strings.TrimSpace(rest[5:]), user, room, flags)
}

// List existing items
if args[0] == `list` {
return item_List(strings.TrimSpace(rest[4:]), user, room)
return item_List(strings.TrimSpace(rest[4:]), user, room, flags)
}

return true, nil
}

func item_List(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func item_List(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

itmNames := []templates.NameDescription{}

Expand Down Expand Up @@ -80,7 +80,7 @@ func item_List(rest string, user *users.UserRecord, room *rooms.Room) (bool, err
return true, nil
}

func item_Spawn(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func item_Spawn(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

itemId := items.FindItem(rest)
if itemId != 0 {
Expand Down Expand Up @@ -109,7 +109,7 @@ func item_Spawn(rest string, user *users.UserRecord, room *rooms.Room) (bool, er
return true, nil
}

func item_Create(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func item_Create(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

var newItemSpec = items.ItemSpec{}

Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.locate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.locate", nil)
Expand Down
16 changes: 8 additions & 8 deletions internal/usercommands/admin.mob.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if user.Permission != users.PermissionAdmin {
user.SendText(`<ansi fg="alert-4">Only admins can use this command</ansi>`)
Expand All @@ -35,23 +35,23 @@ func Mob(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {

// Create a new mob
if args[0] == `create` {
return mob_Create(strings.TrimSpace(rest[6:]), user, room)
return mob_Create(strings.TrimSpace(rest[6:]), user, room, flags)
}

// Spawn a mob instance
if args[0] == `spawn` {
return mob_Spawn(strings.TrimSpace(rest[5:]), user, room)
return mob_Spawn(strings.TrimSpace(rest[5:]), user, room, flags)
}

// List existing mobs
if args[0] == `list` {
return mob_List(strings.TrimSpace(rest[4:]), user, room)
return mob_List(strings.TrimSpace(rest[4:]), user, room, flags)
}

return true, nil
}

func mob_List(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func mob_List(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

mobNames := []templates.NameDescription{}

Expand Down Expand Up @@ -83,7 +83,7 @@ func mob_List(rest string, user *users.UserRecord, room *rooms.Room) (bool, erro
return true, nil
}

func mob_Spawn(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func mob_Spawn(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

c := configs.GetConfig()

Expand Down Expand Up @@ -127,7 +127,7 @@ func mob_Spawn(rest string, user *users.UserRecord, room *rooms.Room) (bool, err
return true, nil
}

func mob_Create(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
func mob_Create(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {

var newMob = mobs.Mob{}

Expand Down Expand Up @@ -220,7 +220,7 @@ func mob_Create(rest string, user *users.UserRecord, room *rooms.Room) (bool, er
}

question.RejectResponse()
return Help(helpCmd+` `+helpRest, user, room)
return Help(helpCmd+` `+helpRest, user, room, flags)
}

raceNameSelection := question.Response
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if user.Permission != users.PermissionAdmin {
user.SendText(`<ansi fg="alert-4">Only admins can use this command</ansi>`)
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.mudmail.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

/*
args := util.SplitButRespectQuotes(rest)
Expand Down
4 changes: 2 additions & 2 deletions internal/usercommands/admin.mute.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.mute", nil)
Expand All @@ -36,7 +36,7 @@ func Mute(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
return true, nil
}

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.mute", nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.paz.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

beamOfLight := colorpatterns.ApplyColorPattern(`beam of light`, `rainbow`)

Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.prepare", nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.questtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/volte6/gomud/internal/util"
)

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

// args should look like one of the following:
// questtoken <tokenname>
Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.redescribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/volte6/gomud/internal/util"
)

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

args := util.SplitButRespectQuotes(rest)

Expand Down
2 changes: 1 addition & 1 deletion internal/usercommands/admin.reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/volte6/gomud/internal/users"
)

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

if rest == "" {
infoOutput, _ := templates.Process("admincommands/help/command.reload", nil)
Expand Down
Loading
Loading