Dev » Lua API » attributedef
← Back to all classes

attributedef

Definitions & Systems 3 Properties 1 Methods

attributedef

The attributedef class represents attribute type descriptors used in the entity stat and attribute system.

Overview

Properties (3)

Property Type Summary
id string Attribute string ID.
index number Internal index of attribute.
isValid boolean Checks if attribute definition is valid.

Methods (1)

Method Signature Returns Summary
attributedef.new(id) attributedef Looks up an attribute definition by string ID.

Detailed Reference

# id PROPERTY
attributedef.id
Attribute string ID.
Parameters
None
Returns
string

Attribute string ID.

Description

Unique attribute identifier (e.g. "health", "hunger", "thirst", "stamina").

# index PROPERTY
attributedef.index
Internal index of attribute.
Parameters
None
Returns
number

Internal integer index.

Description

Fast integer lookup index.

# isValid PROPERTY
attributedef.isValid
Checks if attribute definition is valid.
Parameters
None
Returns
boolean

True if attribute definition exists.

Description

Returns true if the attribute definition is registered.

# new METHOD
attributedef.new(id)
Looks up an attribute definition by string ID.
Parameters
ParameterTypeDefaultDescription
idstring

Attribute string identifier.

Returns
attributedef

Attribute descriptor.

Description

Returns the descriptor matching id.

local healthAttr = attributedef.new("health")