Skip to main content

Entity userdata

Entity userdata retains a serial-checked handle, not ownership of the native object. Check is_valid() before using a retained handle. Methods resolving native state return nil, reason when stale/unavailable; invalid argument types raise errors. handle() and index() inspect the stored handle even after invalidation. Derived types inherit the base methods. Tables and vectors returned by snapshot methods are independent Lua values, not live writable views.

is_valid​

entity:is_valid()

Returns: boolean.

True when the stored serial-checked handle still resolves to a native entity.

handle​

entity:handle()

Returns: integer.

The stored complete entity handle, including its serial; validity is not checked.

index​

entity:index()

Returns: integer.

Entry index extracted from the stored handle; validity is not checked.

classname​

entity:classname()

Returns: string; or nil, reason.

Native schema class name. Missing class data fails with a reason.

origin​

entity:origin()

Returns: Vector; or nil, reason.

Copies absolute scene-node origin. A missing node fails with a reason.

health​

entity:health()

Returns: integer; or nil, reason.

Reads the native health value.

team​

entity:team()

Returns: integer; or nil, reason.

Reads the native team number.

is_alive​

entity:is_alive()

Returns: boolean; or nil, reason.

Reads native alive state.

is_dormant​

entity:is_dormant()

Returns: boolean; or nil, reason.

Reads scene-node dormancy via the supported schema. Missing node or dormancy schema fails with a reason.

scene_node​

entity:scene_node()

Returns: SceneNode table; or nil, reason.

Copies origin, rotation, and render_origin vectors. See structures.

model​

entity:model()

Returns: Model table; or nil, reason.

Copies bone_count and hitbox_set. Requires a model entity, skeleton, and available model. See structures.

bone​

entity:bone(index)

Returns: Bone table; or nil, reason.

Integer zero-based native bone index. Missing skeleton/model, invalid index, or unavailable transform fails with a reason. See structures.

hitbox​

entity:hitbox(index_or_name)

Returns: Hitbox table; or nil, reason.

Accepts a zero-based numeric index or one of: head, neck, pelvis, body, thorax, chest, upper chest, right/left thigh, calf, foot, hand, upper arm, or forearm. Names are case-insensitive and ignore spaces, underscores, and hyphens; unknown names yield an unavailable result. Resolves the hitbox and its associated bone; unavailable data fails with a reason. See structures.

Controller​

Inherits all Entity methods above.

controller-pawn​

controller:pawn()

Returns: Pawn; or nil, reason.

Resolves the controller's current pawn handle.

controller-name​

controller:name()

Returns: string; or nil, reason.

Returns the current native player name.

controller-steam_id​

controller:steam_id()

Returns: decimal string; or nil, reason.

Returns the full unsigned Steam ID as text to preserve its 64-bit precision. Zero IDs are unavailable.

controller-tick_base​

controller:tick_base()

Returns: integer; or nil, reason.

Reads the controller's tick base.

controller-is_local​

controller:is_local()

Returns: boolean; or nil, reason.

Compares against the current local controller.

Pawn​

Inherits all Entity methods above.

pawn-controller​

pawn:controller()

Returns: Controller; or nil, reason.

Resolves the pawn's controller handle.

pawn-weapon​

pawn:weapon()

Returns: Weapon; or nil, reason.

Resolves the active weapon.

pawn-eye_position​

pawn:eye_position()

Returns: Vector; or nil, reason.

Copies the pawn's current eye position.

pawn-velocity​

pawn:velocity()

Returns: Vector; or nil, reason.

Copies absolute velocity.

pawn-recoil​

pawn:recoil()

Returns: Vector; or nil, reason.

Copies recoil angles.

Weapon​

Inherits all Entity methods above.

weapon-data​

weapon:data()

Returns: WeaponData table; or nil, reason.

Copies native weapon data; unavailable data fails with a reason. See structures.

weapon-inaccuracy​

weapon:inaccuracy([alternate = false])

Returns: number; or nil, reason.

Reads inaccuracy, passing the second argument's truthiness to the native alternate-mode option.

weapon-spread​

weapon:spread([alternate = false])

Returns: number; or nil, reason.

Reads spread, passing the second argument's truthiness to the native alternate-mode option.

weapon-recoil_index​

weapon:recoil_index()

Returns: number; or nil, reason.

Reads current weapon recoil index.

weapon-clip​

weapon:clip()

Returns: integer; or nil, reason.

Reads primary clip count.