Skip to content

LocEntity

Overview

An LocEntity represents an instance of an LocType that is currently active in the game world.

See LocList for information on how to access LocEntities.


Info

An LocEntity is a Proxy usertype, which means it is safe to copy and store in your scripts.
It cannot, however, be used with any persistent storage.

Warning

Use LocEntity.isValid to confirm that an entity still exists before trying to access its properties.
Entities can be removed from the client by the server for various reasons, i.e. due to moving beyond the player view distance or being deleted by the server.
When an entity is removed it will become invalid, and any copies of this usertype should be disposed of.

If the same entity is re-created on the client, such as walking back into visibility range, then a different new LocEntity will be created.

Information available within an LocEntity includes:

  • LocType
  • World position
  • Rotation type
  • Visibility status

Enumerations

RotationType

Indicates the 90-degree rotation type a LocEntity is using.
Also see LocEntity.rotationType.

Name Value
ZERO 0
NINETY 1
ONEEIGHTY 2
TWOSEVENTY 3

Examples

-- Iterate all available LocEntities
local allLocs = LocList.All()
for _,locEntity in ipairs(allLocs) do
    if locEntity.config == config.Loc.FFH_WILLOW_TREE_TRUNK and locEntity.coordGrid == CoordGrid._0_50_50_35_32 then
        -- Found the willow tree next to the Lumbridge Bridge
    end
end

Constructors

Info

This usertype has no constructor, and you cannot create your own.

Properties

Info

All properties are read-only.

Name Type Description
isValid Boolean Whether this entity still exists.
Dispose of this usertype object when invalid.
displayName String The display name of this entity.
config LocType The config used by this entity.
parentConfig LocType The parent config used by this entity, if it is a MultiLoc.
configID Integer The ID of the config used by this entity.
parentConfigID Integer The ID of the parent config used by this entity, if it is a MultiLoc.
isMultiLoc Boolean Whether this entity is a MultiLoc.
position Vector3 The world position of this entity.
coordGrid CoordGrid Returns the CoordGrid tile this entity is currently on.
shapeType LocShapeType The LocShapeType being used by this entity.
rotationType RotationType The 90-degree rotation type being used by this entity.
width Integer The width of this entity on the X axis, in grid units.
This taken from entity's LocType config after being rotated by rotationType.
length Integer The length of this entity on the Z axis, in grid units.
This taken from entity's LocType config after being rotated by rotationType.
isHidden Boolean Whether this entity has been hidden by game logic.
isRoofRemoved Boolean Whether this entity has been hidden by the Remove Roof system.
currentAnimation SeqType The current animation being played by this entity.
Returns nil if none is set.