core

package module
v0.0.0-...-0569af2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions

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

Lua based scripting

func NewActions

func NewActions() *Actions

Constructor

func (*Actions) Call

func (a *Actions) Call(key string, self, actor, target *Object) (bool, string)

Calls the given function, given a range of 1 to 3 objects (use temporary objects for short-term variables)

func (*Actions) Get

func (a *Actions) Get(key string) string

Obtains the function's code, will return an empty string on missing or Restricted functions

func (*Actions) Has

func (a *Actions) Has(key string) bool

Checks if that function key / name exists

func (*Actions) Private

func (a *Actions) Private(key string) bool

Private prevents being changed Client side, but can be read/called

func (*Actions) Restricted

func (a *Actions) Restricted(key string) bool

Restricted prevents being changed or called on Client side

func (*Actions) Safe

func (a *Actions) Safe() bool

If we are running safely Server side or Client side

func (*Actions) Set

func (a *Actions) Set(key string, code string)

Assigns the function

Will not assign if Client side, and it is a Private or Restricted function

func (*Actions) Unsafe

func (a *Actions) Unsafe()

Marks us running unsafely on Client side

type Attr

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

A single Attribute, with no name

func NewAttr

func NewAttr() *Attr

Constructor

func (*Attr) Array

func (a *Attr) Array() []any

Returns the value as []any

Returns nil if the value isn't an array or not []any

func (*Attr) ArrayBool

func (a *Attr) ArrayBool() []bool

Returns the value as []bool

Returns nil if the value isn't an array or not []bool

func (*Attr) ArrayFloat32

func (a *Attr) ArrayFloat32() []float32

Returns the value as []float32

Returns nil if the value isn't an array or not []float32

func (*Attr) ArrayFloat64

func (a *Attr) ArrayFloat64() []float64

Returns the value as []float64

Returns nil if the value isn't an array or not []float64

func (*Attr) ArrayInt32

func (a *Attr) ArrayInt32() []int32

Returns the value as []int32

Returns nil if the value isn't an array or not []int32

func (*Attr) ArrayInt64

func (a *Attr) ArrayInt64() []int64

Returns the value as []int64

Returns nil if the value isn't an array or not []int64

func (*Attr) ArrayString

func (a *Attr) ArrayString() []string

Returns the value as []string

Returns nil if the value isn't an array or not []string (currently no conversion)

func (*Attr) ArrayUint32

func (a *Attr) ArrayUint32() []uint32

Returns the value as []uint32

Returns nil if the value isn't an array or not []uint32

func (*Attr) ArrayUint64

func (a *Attr) ArrayUint64() []uint64

Returns the value as []uint64

Returns nil if the value isn't an array or not []uint64

func (*Attr) Bool

func (a *Attr) Bool() bool

Returns the value as bool

If it's a complex type returns if the length is not 0

func (*Attr) Complex

func (a *Attr) Complex() (bool, bool)

If the value is an array/slice or map

Returns array, map booleans

func (*Attr) Float32

func (a *Attr) Float32() float32

Returns the value as float32

If it's a complex type return it's length

func (*Attr) Float64

func (a *Attr) Float64() float64

Returns the value as float64

If it's a complex type return it's length

func (*Attr) Get

func (a *Attr) Get() any

Obtain the attribute, keeping it in a unknown value

func (*Attr) Int32

func (a *Attr) Int32() int32

Returns the value as int32

If it's a complex type return it's length

func (*Attr) Int64

func (a *Attr) Int64() int64

Returns the value as int64

If it's a complex type return it's length

func (*Attr) Map

func (a *Attr) Map() map[string]any

Returns the value as map[string]any

Returns nil if the value isn't a map or not map[string]any

func (*Attr) MapBool

func (a *Attr) MapBool() map[string]bool

Returns the value as map[string]bool

Returns nil if the value isn't a map or not map[string]bool

func (*Attr) MapFloat32

func (a *Attr) MapFloat32() map[string]float32

Returns the value as map[string]float32

Returns nil if the value isn't a map or not map[string]float32

func (*Attr) MapFloat64

func (a *Attr) MapFloat64() map[string]float64

Returns the value as map[string]float64

Returns nil if the value isn't a map or not map[string]float64

func (*Attr) MapInt32

func (a *Attr) MapInt32() map[string]int32

Returns the value as map[string]int32

Returns nil if the value isn't a map or not map[string]int32

func (*Attr) MapInt64

func (a *Attr) MapInt64() map[string]int64

Returns the value as map[string]int64

Returns nil if the value isn't a map or not map[string]int64

func (*Attr) MapString

func (a *Attr) MapString() map[string]string

Returns the value as map[string]string

Returns nil if the value isn't a map or not map[string]string

func (*Attr) MapUint32

func (a *Attr) MapUint32() map[string]uint32

Returns the value as map[string]uint32

Returns nil if the value isn't a map or not map[string]uint32

func (*Attr) MapUint64

func (a *Attr) MapUint64() map[string]uint64

Returns the value as map[string]uint64

Returns nil if the value isn't a map or not map[string]uint64

func (*Attr) MarshalJSON

func (a *Attr) MarshalJSON() ([]byte, error)

Convert the Attribute into JSON

func (*Attr) Set

func (a *Attr) Set(val any)

Assign the value and obtain it's type

func (*Attr) String

func (a *Attr) String() string

Obtain the value as string

func (*Attr) Type

func (a *Attr) Type() string

Obtain the cached type of the value

func (*Attr) Uint32

func (a *Attr) Uint32() uint32

Returns the value as uint32

If it's a complex type return it's length

func (*Attr) Uint64

func (a *Attr) Uint64() uint64

Returns the value as uint64

If it's a complex type return it's length

func (*Attr) UnmarshalJSON

func (a *Attr) UnmarshalJSON(data []byte) error

Convert the JSON into a Attribute

type Attributes

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

Attributes or Variables of an Object

func NewAttributes

func NewAttributes() *Attributes

Constructor

func (*Attributes) Array

func (a *Attributes) Array(key string) []any

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayBool

func (a *Attributes) ArrayBool(key string) []bool

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayFloat32

func (a *Attributes) ArrayFloat32(key string) []float32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayFloat64

func (a *Attributes) ArrayFloat64(key string) []float64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayInt32

func (a *Attributes) ArrayInt32(key string) []int32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayInt64

func (a *Attributes) ArrayInt64(key string) []int64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayString

func (a *Attributes) ArrayString(key string) []string

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayUint32

func (a *Attributes) ArrayUint32(key string) []uint32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) ArrayUint64

func (a *Attributes) ArrayUint64(key string) []uint64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) Bool

func (a *Attributes) Bool(key string) bool

Obtain the value of the Attribute

Returns false on missing or Restricted (or if the value actually is false)

func (*Attributes) Complex

func (a *Attributes) Complex(key string) (bool, bool)

Complex returns if the value of the Attribute is array or map (returning array or map as booleans)

Returns false and false on missing or Restricted (Or if the value isn't Complex)

func (*Attributes) Float32

func (a *Attributes) Float32(key string) float32

Obtain the value of the Attribute

Returns 0.0 on missing or Restricted (or if the value actually is 0.0)

func (*Attributes) Float64

func (a *Attributes) Float64(key string) float64

Obtain the value of the Attribute

Returns 0.0 on missing or Restricted (or if the value actually is 0.0)

func (*Attributes) Get

func (a *Attributes) Get(key string) any

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually is nil)

func (*Attributes) Has

func (a *Attributes) Has(key string) bool

Checks if the variable/attribute exists

Also validates the underlying attribute structure for nil cases

func (*Attributes) Int32

func (a *Attributes) Int32(key string) int32

Obtain the value of the Attribute

Returns 0 on missing or Restricted (or if the value actually is 0)

func (*Attributes) Int64

func (a *Attributes) Int64(key string) int64

Obtain the value of the Attribute

Returns 0 on missing or Restricted (or if the value actually is 0)

func (*Attributes) Map

func (a *Attributes) Map(key string) map[string]any

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapBool

func (a *Attributes) MapBool(key string) map[string]bool

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapFloat32

func (a *Attributes) MapFloat32(key string) map[string]float32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapFloat64

func (a *Attributes) MapFloat64(key string) map[string]float64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapInt32

func (a *Attributes) MapInt32(key string) map[string]int32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapInt64

func (a *Attributes) MapInt64(key string) map[string]int64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapString

func (a *Attributes) MapString(key string) map[string]string

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapUint32

func (a *Attributes) MapUint32(key string) map[string]uint32

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MapUint64

func (a *Attributes) MapUint64(key string) map[string]uint64

Obtain the value of the Attribute

Returns nil on missing or Restricted (or if the value actually isn't Complex)

func (*Attributes) MarshalJSON

func (a *Attributes) MarshalJSON() ([]byte, error)

Converts Attriubtes into JSON

func (*Attributes) Private

func (a *Attributes) Private(key string) bool

Client side can't change, but can read

func (*Attributes) Restricted

func (a *Attributes) Restricted(key string) bool

Client side can't change nor read

func (*Attributes) Safe

func (a *Attributes) Safe() bool

If running Server side or Client side

func (*Attributes) Set

func (a *Attributes) Set(key string, val any)

Assigns the attribute

Prevents assignment on Private and Restricted value under Client side

func (*Attributes) String

func (a *Attributes) String(key string) string

Obtain the value of the Attribute

Returns empty on missing or Restricted (or if the value actually is empty)

func (*Attributes) Uint32

func (a *Attributes) Uint32(key string) uint32

Obtain the value of the Attribute

Returns 0 on missing or Restricted (or if the value actually is 0)

func (*Attributes) Uint64

func (a *Attributes) Uint64(key string) uint64

Obtain the value of the Attribute

Returns 0 on missing or Restricted (or if the value actually is 0)

func (*Attributes) UnmarshalJSON

func (a *Attributes) UnmarshalJSON(data []byte) error

Converts JSON into Attributes

func (*Attributes) Unsafe

func (a *Attributes) Unsafe()

Marks running Client side

type Groups

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

Isolation layer for Objects

func NewGroups

func NewGroups() *Groups

Constructor

func (*Groups) Get

func (g *Groups) Get(key string) uint32

Obtain the group's level

Returns the level or 0 for missing or Restricted groups

func (*Groups) Has

func (g *Groups) Has(key string) bool

Checks if the group exists

func (*Groups) Is

func (g *Groups) Is(key string) bool

Checks if the group is not 0

func (*Groups) Private

func (g *Groups) Private(key string) bool

Prevents the group from being changed Client side, but can be read Client side

func (*Groups) Restricted

func (g *Groups) Restricted(key string) bool

Prevents the group from being changed and read Client side

func (*Groups) Safe

func (g *Groups) Safe() bool

If running Server side or Client side

func (*Groups) Set

func (g *Groups) Set(key string, level uint32)

Assigns a group with a level

Prevents assignment if Client side and the group is Private or Restricted

func (*Groups) Unsafe

func (g *Groups) Unsafe()

Marks this running Client side

type Inventory

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

func NewInventory

func NewInventory() *Inventory

func (*Inventory) Count

func (i *Inventory) Count(obj_id uint64) (uint64, bool)

func (*Inventory) FindAll

func (i *Inventory) FindAll(obj_id uint64) ([]uint64, bool)

func (*Inventory) FindOne

func (i *Inventory) FindOne(obj_id uint64) (uint64, bool)

func (*Inventory) Get

func (i *Inventory) Get(slot uint64) uint64

func (*Inventory) Has

func (i *Inventory) Has(slot uint64) bool

func (*Inventory) Safe

func (i *Inventory) Safe() bool

func (*Inventory) Set

func (i *Inventory) Set(slot uint64, obj_id uint64)

func (*Inventory) Unsafe

func (i *Inventory) Unsafe()

type Object

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

func NewObject

func NewObject() *Object

func NewTempObject

func NewTempObject() *Object

func (*Object) Bool

func (o *Object) Bool(key string) bool

func (*Object) Call

func (o *Object) Call(fun string, args ...*Object) (bool, string)

func (*Object) Define

func (o *Object) Define(name, code string)

func (*Object) Float32

func (o *Object) Float32(key string) float32

func (*Object) Float64

func (o *Object) Float64(key string) float64

func (*Object) HasActions

func (o *Object) HasActions() bool

func (*Object) HasAttributes

func (o *Object) HasAttributes() bool

func (*Object) HasGroup

func (o *Object) HasGroup() bool

func (*Object) HasInventory

func (o *Object) HasInventory() bool

func (*Object) Id

func (o *Object) Id() uint64

func (*Object) Int32

func (o *Object) Int32(key string) int32

func (*Object) Int64

func (o *Object) Int64(key string) int64

func (*Object) Is

func (o *Object) Is(key string) bool

func (*Object) IsTemp

func (o *Object) IsTemp() bool

func (*Object) Level

func (o *Object) Level(key string, level uint32)

func (*Object) Name

func (o *Object) Name() string

func (*Object) Owner

func (o *Object) Owner() uint64

func (*Object) Set

func (o *Object) Set(key string, val any)

func (*Object) String

func (o *Object) String(key string) string

func (*Object) Uint32

func (o *Object) Uint32(key string) uint32

func (*Object) Uint64

func (o *Object) Uint64(key string) uint64

type Storage

type Storage struct {
	BaseDir string
}

func NewStorage

func NewStorage() *Storage

func (*Storage) ActionLock

func (s *Storage) ActionLock(id uint64) bool

func (*Storage) ActionLocked

func (s *Storage) ActionLocked(id uint64) bool

func (*Storage) ActionUnlock

func (s *Storage) ActionUnlock(id uint64)

func (*Storage) AttrLock

func (s *Storage) AttrLock(id uint64) bool

func (*Storage) AttrLocked

func (s *Storage) AttrLocked(id uint64) bool

func (*Storage) AttrUnlock

func (s *Storage) AttrUnlock(id uint64)

func (*Storage) GetActions

func (s *Storage) GetActions(id uint64) (*Actions, error)

func (*Storage) GetAttributes

func (s *Storage) GetAttributes(id uint64) (*Attributes, error)

func (*Storage) GetGroups

func (s *Storage) GetGroups(id uint64) (*Groups, error)

func (*Storage) GetInventory

func (s *Storage) GetInventory(id uint64) (*Inventory, error)

func (*Storage) GetObject

func (s *Storage) GetObject(id uint64) (*Object, error)

func (*Storage) GroupLock

func (s *Storage) GroupLock(id uint64) bool

func (*Storage) GroupLocked

func (s *Storage) GroupLocked(id uint64) bool

func (*Storage) GroupUnlock

func (s *Storage) GroupUnlock(id uint64)

func (*Storage) HasAction

func (s *Storage) HasAction(id uint64) bool

func (*Storage) HasAttr

func (s *Storage) HasAttr(id uint64) bool

func (*Storage) HasGroup

func (s *Storage) HasGroup(id uint64) bool

func (*Storage) HasInv

func (s *Storage) HasInv(id uint64) bool

func (*Storage) InvLock

func (s *Storage) InvLock(id uint64) bool

func (*Storage) InvLocked

func (s *Storage) InvLocked(id uint64) bool

func (*Storage) InvUnlock

func (s *Storage) InvUnlock(id uint64)

func (*Storage) NewObject

func (s *Storage) NewObject() *Object

func (*Storage) NewTempObject

func (s *Storage) NewTempObject() *Object

func (*Storage) NextId

func (s *Storage) NextId() (uint64, bool)

func (*Storage) Postcheck

func (s *Storage) Postcheck(id uint64)

func (*Storage) Precheck

func (s *Storage) Precheck()

func (*Storage) SetAction

func (s *Storage) SetAction(id uint64, act *Actions) error

func (*Storage) SetAttr

func (s *Storage) SetAttr(id uint64, attr *Attributes) error

func (*Storage) SetGroup

func (s *Storage) SetGroup(id uint64, group *Groups) error

func (*Storage) SetInv

func (s *Storage) SetInv(id uint64, inv *Inventory) error

func (*Storage) SetObject

func (s *Storage) SetObject(obj *Object) error

Jump to

Keyboard shortcuts

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