Type Entity

Entity

Methods

addCallback( name, identifier, func ) Adds a callback to an entity for a specific event.
ang() Returns the angle of the entity
attachments() Returns a table of all attachments the entity's model has, or nil if it has none.
boundingRadius() Returns the distance to the furthest corner on the entity's bounding box.
callOnRemove( identifier, callback, ... ) Registers a callback to run on removal of this entity.
class() Returns the class of the entity
color() Returns the entity's colour.
coreHealth() Returns the health of the ship core the entity is assigned to.
coreMaxHealth() Returns the maximum health of the ship core the entity is assigned to.
createWire( ent, input, output ) Wires the input of self to the output of Ent.
deleteWire( input ) Deletes the wire leading to self's input.
entHealth() Returns the entity's current health.
entMaxHealth() Returns the entity's maximum health.
eyeAngles() Gets the entitiy's eye angles
eyePos() Gets the entity's eye position
followBone( parent, boneID ) Parents the entity to the given parent's bone.
forward() Gets the entity's forward direction vector.
getAttachment( attachment ) Returns a table containing the position and angles of the given attachment, if it exists.
getBodygroup( id ) Gets the bodygroup the current ID is using.
getBodygroupCount( id ) Gets the bodygroup count.
getBoneCount() Gets the number of bones the entity's model has defined.
getBoneName( boneID ) Gets the nice name of the bone with the given ID on the entity.
getBoneParent( boneID ) Gets the ID of the bone that is the parent bone for the given bone ID on the entity.
getBonePosition( boneID ) Gets the position and angles of the bone with the given ID on the entity.
getChildBones( boneID ) Gets the IDs of all child bones for the given bone ID on the entity.
getChildren() Returns a list of all child entities parented to this entity.
getClippingPlanes() Returns the clipping planes applied to the entity using the physical clipping tool.
getCollisionGroup() Gets the collision group of an entity.
getConstraints( filter ) Gets a table of all constrained entities.
getCore() Returns the ship core that the entity is assigned to, or nil if it does not have one.
getCreationID() Returns the creation ID of the entity.
getCycle() Returns the current cycle (frame) of the playing sequence (animation), as a value between 0 and 1.
getDoorState() Returns the state of an SBEP door.
getDoors() Returns the door entities an SBEP door controller is controlling.
getEFlags() Returns a mask indicating the EFL_* flags the entity has currently set.
getEnvironmentData() Gets the environment data table of an entity.
getFlags() Returns a mask indicating the FL_* flags the entity has currently set.
getGroundEntity() Returns the entity that this entity is currently standing on.
getMapCreationID() Returns the map creation ID of the entity (or -1 if the entity is not part of the map).
getMaterials() Returns all materials on the given entity.
getModelBounds() Returns the min and max bounds for the entity's model, ignoring its current scale.
getNode() Returns the resource node the entity is connected to, or nil.
getNumPoseParameters() Returns the number of pose parameters assigned to the entity's current model.
getParent() Returns the parent of the given entity.
getPhysicsObject() Gets the physics object associated with the entity.
getPhysicsObjectCount() Gets the number of physics objects the entity has.
getPhysicsObjectNum( index ) Gets the physics object at the given index.
getPlaybackRate() Returns the current playback rate of the playing sequence (animation).
getPoseParameter( id ) Gets the given pose parameter's current value.
getPoseParameterName( id ) Returns the name of the pose parameter with the given ID.
getPoseParameterRange( id ) Returns the valid range of values for the pose parameter with the given ID.
getPrintName() Returns the print name of the entity if it has one, otherwise nil.
getPropScale() Returns the scaling used to resize the given entity, or 1 if no scaling is applied.
getRenderMode() Returns the entity's current render mode.
getResourceAmount( resource ) Retrieves the current supply of the given resource.
getRotatedAABB( mins, maxs ) Returns world-space extents for the entity given local-space mins and maxs.
getScreen() Returns the screen a repeater is linked to.
getSequence() Returns the current sequence (animation) playing on the given entity.
getSequenceList() Returns a list of all sequences (animations) on the model.
getSequenceName( sequence ) Returns the name of the given sequence (animation) index.
getSingleConstrainedEnts() Gets all entities constrained to self, non-recursive.
getSubMaterial( index ) Returns the currently set sub-material at the given index.
getSubMaterialColor( index ) Returns the currently set sub-material colour at the given index.
getSubsystemHealth() Returns the entity's subsystem health, if it has any.
getUnitCapacity( resource ) Retrieves the maximum supply of the given resource.
getWireName() Gets the name set with the wire namer tool.
getWirelink() Gets the wirelink associated with the given entity (if the entity is wireable).
getWorldTransformMatrix() Returns the entity's world transform matrix.
index() Returns the EntIndex of the entity
isConstrained() Returns true if the entity is constrained to something.
isDormant() Returns true if the entity is dormant, that is, outside the current PVS of the local player.
isEFlagSet( flag ) Returns true if the given EFL_* flag is set on the entity.
isFlagSet( flag ) Returns true if the given FL_* flag is set on the entity.
isNPC() Returns whether the given entity is an NPC.
isPlayer() Returns whether the given entity is a player.
isValid() Checks if an entity is valid.
isVehicle() Returns whether the given entity is a vehicle.
isWeapon() Returns whether the given entity is a weapon.
isWeldedTo() Returns the first entity that is welded to the given entity.
link( ent ) Links two entities.
lookupBone( boneName ) Looks up the ID for an entity's bone using its nice name.
lookupSequence( name ) Looks up the index of the given animation name.
material() Returns the entity's material.
model() Gets the model of an entity
nocollide( ent, bone1, bone2 ) Creates a nocollide constraint between two entities.
obbCenter() Returns the local position of the entity's outer bounding box Note that this will return a zero-vector on clientside models as it is derived from collision data.
obbCenterW() Returns the world position of the entity's outer bounding box.
obbMaxs() Returns the max of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.
obbMins() Returns the min of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.
obbSize() Returns the x, y, z size of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.
owner() Gets the owner of the entity
pos() Returns the position of the entity
pullResource( resource, amount ) Pulls the given amount of resource from node 2 to node 1 instantly.
pushResource( resource, amount ) Pushes the given amount of resource from node 1 to node 2 instantly.
remove() Removes the given entity.
removeCallOnRemove( identifier ) Removes a registered removal callback.
removeCallback( name, identifier ) Removes a callback added by Entity:addCallback().
removeTrail() Removes an entity's sprite trail.
right() Gets the entity's right direction vector.
sequenceDuration() Returns the duration of the current playing sequence (animation).
setAlpha( alpha ) Sets the alpha of the given entity without changing the colour.
setAng( ang ) Sets the entity's angles
setBodygroup( id, subModelID ) Sets the sub model to be rendered under the given bodygroup of the given entity.
setCollisionGroup( group ) Sets the entity's collision group, which determines what it collides with.
setColor( r, g, b, a ) Sets the entity's colour.
setLocalAng( ang ) Sets the entity's angles locally.
setMaterial( material ) Sets an entity's material.
setModel( model ) Sets the model of the given entity (does not change physics!)
setNotSolid( notsolid ) Sets the entity solid state
setParent( ent ) Parents the first entity to the second.
setPos( pos, flags ) Sets the entitiy's position.
setPullRate( resource, rate ) Sets the pull rate (node 2 to node 1) on the given resource valve.
setPushRate( resource, rate ) Sets the push rate (node 1 to node 2) on the given resource valve.
setRenderMode( mode ) Sets the render mode of the given entity.
setSkin( skin ) Sets the skin of an entity.
setSubMaterial( index, material ) Sets an entity's sub-material.
setSubMaterialColor( index, colour ) Sets an entity's sub-material colour.
skin() Returns the entity's skin.
spriteTrail( colour, startSize, endSize, length, material ) Adds/updates a sprite trail on the given entity.
toLocal( value ) Converts an angle or vector in world space to entity local space.
toWorld( value ) Converts an angle or vector in entity local space to world space.
unconstrain( type ) Removes constraints from the given entity.
unlink() Unlinks the given entity from its resource node.
up() Gets the entity's upward direction vector.
vel() Returns the velocity of the entity
waterLevel() Returns the entity's water level.
weldTo( ent, bone1, bone2, forceLimit, noCollide, deleteEnt1OnBreak ) Creates a weld constraint between two entities.


Methods

Entity:addCallback( name, identifier, func )
Adds a callback to an entity for a specific event. Valid events are: - PhysicsCollide

Environment:

Shared

Parameters:

  • name: The name of the event to add a callback for.
  • identifier: The identifier for the event.
  • func: The function to call when the event is fired.

Usage:

    -- Adding a PhysicsCollide callback 
    Entity:addCallback( "PhysicsCollide", "MyUniqueName", function( Ent, CollisionData ) 
    	print( Ent, "hit", CollisionData.HitEntity, "with speed", CollisionData.Speed ) 
    end )
Entity:ang()
Returns the angle of the entity

Environment:

Shared

Return value:

    (Angle) The angle
Entity:attachments()
Returns a table of all attachments the entity's model has, or nil if it has none.

Environment:

Shared
Entity:boundingRadius()
Returns the distance to the furthest corner on the entity's bounding box. Note that this will return 0 on clientside models as it is derived from collision data.

Environment:

Shared
Entity:callOnRemove( identifier, callback, ... )
Registers a callback to run on removal of this entity.

Environment:

Shared

Parameters:

  • identifier: A unique string identifier for this callback. Used if you want to remove it later.
  • callback: The function to run when the entity is removed. Receives the entity, then the arguments passed to this.
  • ...: Arguments to pass to the callback.
Entity:class()
Returns the class of the entity

Environment:

Shared

Return value:

    (string) The string class name
Entity:color()
Returns the entity's colour.

Environment:

Shared
Entity:coreHealth()
Returns the health of the ship core the entity is assigned to.

Environment:

Server
Entity:coreMaxHealth()
Returns the maximum health of the ship core the entity is assigned to.

Environment:

Server
Entity:createWire( ent, input, output )
Wires the input of self to the output of Ent.

Deprecated: Use wire.create

Environment:

Server

Parameters:

  • ent: The entity to wire to.
  • input: The name of the input on self to wire.
  • output: The name of the output on Ent to wire to.

Return value:

    (boolean) True if successful, false, error if not.
Entity:deleteWire( input )
Deletes the wire leading to self's input.

Deprecated: Use wire.delete

Environment:

Server

Parameters:

  • input: The name of the input to unwire.

Return value:

    (boolean) True if successful, false, error if not.
Entity:entHealth()
Returns the entity's current health.

Environment:

Server
Entity:entMaxHealth()
Returns the entity's maximum health.

Environment:

Server
Entity:eyeAngles()
Gets the entitiy's eye angles

Environment:

Shared
Entity:eyePos()
Gets the entity's eye position

Environment:

Shared
Entity:followBone( parent, boneID )
Parents the entity to the given parent's bone.

Environment:

Server

Parameters:

  • (Entity) parent: The parent entity to attach this entity to.
  • (number) boneID: The ID of the bone on the parent to attach to.
Entity:forward()
Gets the entity's forward direction vector.

Environment:

Shared
Entity:getAttachment( attachment )
Returns a table containing the position and angles of the given attachment, if it exists.

Environment:

Shared

Parameters:

  • attachment: The attachment name to get the position/angle for.

Return value:

    (PosAngData) A table with fields "Pos" and "Ang", or nil if no such attachment exists.
Entity:getBodygroup( id )
Gets the bodygroup the current ID is using.

Environment:

Shared

Parameters:

  • id: Bodygroup ID.
Entity:getBodygroupCount( id )
Gets the bodygroup count.

Environment:

Shared

Parameters:

  • id: Bodygroup ID.
Entity:getBoneCount()
Gets the number of bones the entity's model has defined.

Environment:

Shared

Return value:

    (number) The number of bones on the entity, or -1 if the number is not known.
Entity:getBoneName( boneID )
Gets the nice name of the bone with the given ID on the entity.

Environment:

Shared

Parameters:

  • boneID: The ID of the bone to get the name of.

Return value:

    (nil | string) The name of the bone, or nil if no such bone exists.
Entity:getBoneParent( boneID )
Gets the ID of the bone that is the parent bone for the given bone ID on the entity.

Environment:

Shared

Parameters:

  • boneID: The ID of the bone to get the parent bone ID for.

Return value:

    (number) The ID of the parent bone, or -1 if no parent bone exists.
Entity:getBonePosition( boneID )
Gets the position and angles of the bone with the given ID on the entity.

Environment:

Shared

Parameters:

  • boneID: The ID of the bone to get the position of.

Return values:

  1. (nil | Vector) The world position of the bone, or nil if no such bone exists.
  2. (nil | Angle) The world angles of the bone.
Entity:getChildBones( boneID )
Gets the IDs of all child bones for the given bone ID on the entity.

Environment:

Shared

Parameters:

  • boneID: The ID of the bone to get child bones for.

Return value:

    (table | nil) A table containing all child bone IDs, or nil if no such bone exists.
Entity:getChildren()
Returns a list of all child entities parented to this entity.

Environment:

Server

Return value:

    (table) A table containing all child entities.
Entity:getClippingPlanes()
Returns the clipping planes applied to the entity using the physical clipping tool.

Environment:

Shared

Return value:

    (table | nil) A table of clipping planes if the entity has been clipped, otherwise nil.
Entity:getCollisionGroup()
Gets the collision group of an entity.

Environment:

Shared

Return value:

    (number) The collision group (one of ents.COLLISION_GROUP_*)
Entity:getConstraints( filter )
Gets a table of all constrained entities.

Deprecated: Use constraint.getAllConstrainedEntities

Environment:

Server

Parameters:

  • (function?) filter: (Optional) Filter function, return true to keep the entity, false to discard it.
Entity:getCore()
Returns the ship core that the entity is assigned to, or nil if it does not have one.

Environment:

Server
Entity:getCreationID()
Returns the creation ID of the entity.

Environment:

Server
Entity:getCycle()
Returns the current cycle (frame) of the playing sequence (animation), as a value between 0 and 1.

Environment:

Shared
Entity:getDoorState()
Returns the state of an SBEP door.

Environment:

Server
Entity:getDoors()
Returns the door entities an SBEP door controller is controlling.

Environment:

Server
Entity:getEFlags()
Returns a mask indicating the EFL_* flags the entity has currently set.

Environment:

Shared
Entity:getEnvironmentData()
Gets the environment data table of an entity.

Environment:

Server

Usage:

    return { 
    	gravity = 1, 
    	radius = 1000, 
    	temperature = 285, 
    	air = { 
    		Oxygen = 20, 
    		Nitrogen = 75, 
    		Hydrogen = 4.5, 
    		CO2 = 0.5 
    	}, 
    	name = "Planet Name", 
    	--Entity = Entity [1000][stargazer_ls_core] 
    }
Entity:getFlags()
Returns a mask indicating the FL_* flags the entity has currently set.

Environment:

Shared
Entity:getGroundEntity()
Returns the entity that this entity is currently standing on.

Environment:

Shared

Return value:

    (Entity) The entity below this entity.
Entity:getMapCreationID()
Returns the map creation ID of the entity (or -1 if the entity is not part of the map).

Environment:

Server
Entity:getMaterials()
Returns all materials on the given entity. Use the index value - 1 in Entity:setSubMaterial() to replace it. Always returns the original materials, is not affected by Entity:setSubMaterial().

Environment:

Shared
Entity:getModelBounds()
Returns the min and max bounds for the entity's model, ignoring its current scale. This works on normal entities and clientside models.

Environment:

Shared

Return values:

  1. (Vector) The position of the local minimum corner of the model's bounding box.
  2. (Vector) The position of the local maximum corner of the model's bounding box.
Entity:getNode()
Returns the resource node the entity is connected to, or nil.

Environment:

Server

Return value:

    (Entity) Resource node entity, potentially two of them for a resource valve.
Entity:getNumPoseParameters()
Returns the number of pose parameters assigned to the entity's current model.

Environment:

Shared
Entity:getParent()
Returns the parent of the given entity. On the server, the instance owner must have toolgun permission on the entity to see its parent. On the client, the entity owner must be known and match the instance owner to see its parent.

Environment:

Shared
Entity:getPhysicsObject()
Gets the physics object associated with the entity.

Environment:

Shared

Return value:

    (PhysObj) The physics object, or nil if it does not have one.
Entity:getPhysicsObjectCount()
Gets the number of physics objects the entity has.

Environment:

Shared

Return value:

    (number) The number of physics objects present.
Entity:getPhysicsObjectNum( index )
Gets the physics object at the given index. Note: indices are 0 based.

Environment:

Shared

Parameters:

  • index: The index of the physics object, starting from 0.

Return value:

    (PhysObj) The physics object, or nil if no such physics object exists.
Entity:getPlaybackRate()
Returns the current playback rate of the playing sequence (animation).

Environment:

Shared
Entity:getPoseParameter( id )
Gets the given pose parameter's current value. Note that on the client, this value is between 0 and 1, whereas on the server this is between the minimum and maximum value in the range.

Environment:

Shared

Parameters:

  • (number) id: The ID of the pose parameter to look up (0-based).
Entity:getPoseParameterName( id )
Returns the name of the pose parameter with the given ID.

Environment:

Shared

Parameters:

  • (number) id: The ID of the pose parameter to look up (0-based).
Entity:getPoseParameterRange( id )
Returns the valid range of values for the pose parameter with the given ID.

Environment:

Shared

Parameters:

  • (number) id: The ID of the pose parameter to get the range for (0-based).

Return values:

  1. (number | nil) The minimum value of the given pose parameter, if the ID is valid. Otherwise nil.
  2. (number | nil) The maximum value of the given pose parameter, if the ID is valid. Otherwise nil.
Entity:getPrintName()
Returns the print name of the entity if it has one, otherwise nil.

Environment:

Shared
Entity:getPropScale()
Returns the scaling used to resize the given entity, or 1 if no scaling is applied.

Environment:

Shared

Return value:

    (number | Vector | VMatrix) Vector or number scale value, depending on the settings used to resize the entity.
Entity:getRenderMode()
Returns the entity's current render mode. See the ents.RENDERMODE_* enums for possible values.

Environment:

Shared

Return value:

    (number) The entity's current render mode.
Entity:getResourceAmount( resource )
Retrieves the current supply of the given resource.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy".
Entity:getRotatedAABB( mins, maxs )
Returns world-space extents for the entity given local-space mins and maxs. Unlike using localToWorld, this creates a true AABB that encompasses the given space regardless of rotation.

Environment:

Shared

Parameters:

  • mins: The OBB mins vector to start the box at.
  • maxs: The OBB maxs vector to end the box at.

Usage:

    -- Get the extents of an AABB containing the entity's OBB entirely. 
    local Mins, Maxs = Ent:getRotatedAABB( Ent:obbMins(), Ent:obbMaxs() ) 
    -- Find all entities inside the entity. If you use Ent:localToWorld() on the OBB, it will not find correctly. 
    local EntsInside = find.inBox( Ent:pos() + Mins, Ent:pos() + Maxs )

Return value:

    (Vector) Mins, Maxs vectors which represent a world-space AABB containing the entire box given (and often more).
Entity:getScreen()
Returns the screen a repeater is linked to.

Environment:

Shared

Return value:

    (Entity) Linked Starfall screen, or nil if no screen is linked.
Entity:getSequence()
Returns the current sequence (animation) playing on the given entity.

Environment:

Shared
Entity:getSequenceList()
Returns a list of all sequences (animations) on the model.

Environment:

Shared
Entity:getSequenceName( sequence )
Returns the name of the given sequence (animation) index.

Environment:

Shared

Parameters:

  • sequence: Sequence index.
Entity:getSingleConstrainedEnts()
Gets all entities constrained to self, non-recursive.

Deprecated: Use constraint.getConstrainedEntities

Environment:

Server
Entity:getSubMaterial( index )
Returns the currently set sub-material at the given index.

Environment:

Shared

Parameters:

  • index: The index from Entity:getMaterials(), minus 1.
Entity:getSubMaterialColor( index )
Returns the currently set sub-material colour at the given index.

Environment:

Shared

Parameters:

  • index: The index from Entity:getMaterials(), minus 1.
Entity:getSubsystemHealth()
Returns the entity's subsystem health, if it has any. Otherwise nil.

Environment:

Server

Return value:

    (number) Subsystem health (between 0 and 100), or nil if the entity is not a subsystem.
Entity:getUnitCapacity( resource )
Retrieves the maximum supply of the given resource.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy".
Entity:getWireName()
Gets the name set with the wire namer tool.

Environment:

Shared
Entity:getWirelink()
Gets the wirelink associated with the given entity (if the entity is wireable).

Environment:

Server

Return value:

    (Wirelink | nil) A wirelink for the given entity, if it has inputs/outputs. Otherwise nil.
Entity:getWorldTransformMatrix()
Returns the entity's world transform matrix. The first 3 columns are a rotation matrix representing the entity's angles, and the last column is its position.

Environment:

Shared

Return value:

    (VMatrix) The entity's world transform as a matrix.
Entity:index()
Returns the EntIndex of the entity

Environment:

Shared

Return value:

    (number) The numerical index of the entity
Entity:isConstrained()
Returns true if the entity is constrained to something.

Deprecated: Use constraint.hasConstraints

Environment:

Server
Entity:isDormant()
Returns true if the entity is dormant, that is, outside the current PVS of the local player.

Environment:

Client
Entity:isEFlagSet( flag )
Returns true if the given EFL_* flag is set on the entity.

Environment:

Shared

Parameters:

  • flag:
Entity:isFlagSet( flag )
Returns true if the given FL_* flag is set on the entity.

Environment:

Shared

Parameters:

  • flag:
Entity:isNPC()
Returns whether the given entity is an NPC.

Environment:

Shared
Entity:isPlayer()
Returns whether the given entity is a player.

Environment:

Shared
Entity:isValid()
Checks if an entity is valid.

Environment:

Shared

Return value:

    (boolean) True if valid, false if not
Entity:isVehicle()
Returns whether the given entity is a vehicle.

Environment:

Shared
Entity:isWeapon()
Returns whether the given entity is a weapon.

Environment:

Shared
Entity:isWeldedTo()
Returns the first entity that is welded to the given entity.

Deprecated: Use constraint.findConstraintEntity( entity, "Weld" )

Environment:

Server
Entity:link( ent )
Links two entities. One should be a resource node.

Environment:

Server

Parameters:

  • ent: Second entity to link to.

Return value:

    (boolean) True if succeeded, false and a failure reason otherwise.
Entity:lookupBone( boneName )
Looks up the ID for an entity's bone using its nice name.

Environment:

Shared

Parameters:

  • boneName: The name of the bone to lookup.

Return value:

    (nil | number) The ID of the bone, or nil if no such bone exists.
Entity:lookupSequence( name )
Looks up the index of the given animation name.

Environment:

Shared

Parameters:

  • name: Animation name.
Entity:material()
Returns the entity's material.

Environment:

Shared
Entity:model()
Gets the model of an entity

Environment:

Shared
Entity:nocollide( ent, bone1, bone2 )
Creates a nocollide constraint between two entities.

Deprecated: Use constraint.noCollide

Environment:

Server

Parameters:

  • (Entity) ent: Second entity.
  • (number?) bone1: Bone on the first entity, defaults to 0.
  • (number?) bone2: Bone on the second entity, defaults to 0.
Entity:obbCenter()
Returns the local position of the entity's outer bounding box Note that this will return a zero-vector on clientside models as it is derived from collision data.

Environment:

Shared

Return value:

    (Vector) The position vector of the outer bounding box center
Entity:obbCenterW()
Returns the world position of the entity's outer bounding box. Note that this will return the entity's position on clientside models as it is derived from collision data.

Environment:

Shared

Return value:

    (Vector) The position vector of the outer bounding box center in world space.
Entity:obbMaxs()
Returns the max of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.

Environment:

Shared

Return value:

    (Vector) The outer bounding box maximum
Entity:obbMins()
Returns the min of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.

Environment:

Shared

Return value:

    (Vector) The outer bounding box minimum
Entity:obbSize()
Returns the x, y, z size of the entity's outer bounding box (local to the entity) Note that this will return a zero-vector on clientside models as it is derived from collision data.

Environment:

Shared

Return value:

    (Vector) The outer bounding box size
Entity:owner()
Gets the owner of the entity

Environment:

Server
Entity:pos()
Returns the position of the entity

Environment:

Shared

Return value:

    (Vector) The position vector
Entity:pullResource( resource, amount )
Pulls the given amount of resource from node 2 to node 1 instantly.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy", "oxygen" etc.
  • amount: Amount to transfer.
Entity:pushResource( resource, amount )
Pushes the given amount of resource from node 1 to node 2 instantly.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy", "oxygen" etc.
  • amount: Amount to transfer.
Entity:remove()
Removes the given entity. This requires the REMOVE_ENTITY permission when running in restricted mode (e.g. executed from the shared area).

Environment:

Server
Entity:removeCallOnRemove( identifier )
Removes a registered removal callback.

Environment:

Shared

Parameters:

  • identifier: The unique string identifier given to Entity:callOnRemove().
Entity:removeCallback( name, identifier )
Removes a callback added by Entity:addCallback().

Environment:

Shared

Parameters:

  • name: The name of the event to remove a callback for.
  • identifier: The identifier given when the callback was added.
Entity:removeTrail()
Removes an entity's sprite trail.

Environment:

Server
Entity:right()
Gets the entity's right direction vector.

Environment:

Shared
Entity:sequenceDuration()
Returns the duration of the current playing sequence (animation).

Environment:

Shared
Entity:setAlpha( alpha )
Sets the alpha of the given entity without changing the colour. Note that this will automatically change the rendermode from ents.RENDERMODE_NORMAL to ents.RENDERMODE_TRANSCOLOR if alpha < 255.

Environment:

Server

Parameters:

  • (number) alpha: The alpha value to set from 0 - 255.
Entity:setAng( ang )
Sets the entity's angles

Environment:

Server

Parameters:

  • ang: New angles
Entity:setBodygroup( id, subModelID )
Sets the sub model to be rendered under the given bodygroup of the given entity.

Environment:

Server

Parameters:

  • (number) id: The ID of the body group to update (0-based).
  • (number) subModelID: The ID of the sub model to use for the given body group (0-based).
Entity:setCollisionGroup( group )
Sets the entity's collision group, which determines what it collides with.

Environment:

Server

Parameters:

  • group: COLLISION_GROUP_* enum.
Entity:setColor( r, g, b, a )
Sets the entity's colour. If you're changing alpha < 255, then you also need to update the rendermode to something like ents.RENDERMODE_TRANSCOLOR.

Environment:

Server

Parameters:

  • (number | Color) r: Either a colour object, or the red number value (default = 255).
  • (number?) g: Green value (default = 255, if R is a number).
  • (number?) b: Blue value (default = 255, if R is a number).
  • (number?) a: Alpha value (default = 255, if R is a number).
Entity:setLocalAng( ang )
Sets the entity's angles locally.

Environment:

Server

Parameters:

  • ang: Local angles.
Entity:setMaterial( material )
Sets an entity's material.

Environment:

Server

Parameters:

  • material: The string path to the material.
Entity:setModel( model )
Sets the model of the given entity (does not change physics!)

Environment:

Server

Parameters:

  • model: The path to the model to use.
Entity:setNotSolid( notsolid )
Sets the entity solid state

Environment:

Server

Parameters:

  • notsolid: Should the entity be not solid?
Entity:setParent( ent )
Parents the first entity to the second.

Environment:

Server

Parameters:

  • (Entity | nil) ent: Entity to parent to. Pass nil to remove the entity's current parent.
Entity:setPos( pos, flags )
Sets the entitiy's position. When called on the instance owner and running in restricted mode (e.g. executed from the shared area), or when called on a player other than the instance owner, this requires the SET_PLAYER_POSITION permission.

Environment:

Server

Parameters:

  • (Vector) pos: New position
  • (number?) flags: Optional bitflags that determine how the entity is moved (see ents.SET_POS_*).

Return values:

  1. (boolean) True if moving the entity succeeded, false otherwise.
  2. (string) If moving the entity failed, the reason why.
Entity:setPullRate( resource, rate )
Sets the pull rate (node 2 to node 1) on the given resource valve.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy", "oxygen" etc.
  • rate: Rate to transfer resources.
Entity:setPushRate( resource, rate )
Sets the push rate (node 1 to node 2) on the given resource valve.

Environment:

Server

Parameters:

  • resource: String resource name, e.g "energy", "oxygen" etc.
  • rate: Rate to transfer resources.
Entity:setRenderMode( mode )
Sets the render mode of the given entity.

Environment:

Server

Parameters:

  • mode: ents.RENDERMODE_* enum.
Entity:setSkin( skin )
Sets the skin of an entity.

Environment:

Server

Parameters:

  • skin: The skin index to use.
Entity:setSubMaterial( index, material )
Sets an entity's sub-material.

Environment:

Server

Parameters:

  • index: The index of the sub-material, get it from getMaterials().
  • material: The material to replace the sub-material with.
Entity:setSubMaterialColor( index, colour )
Sets an entity's sub-material colour.

Environment:

Server

Parameters:

  • index: The index of the sub-material, get it from getMaterials().
  • colour: The colour to set on the sub-material.
Entity:skin()
Returns the entity's skin.

Environment:

Shared
Entity:spriteTrail( colour, startSize, endSize, length, material )
Adds/updates a sprite trail on the given entity.

Environment:

Server

Parameters:

  • colour: The colour of the trail.
  • startSize: The starting size of the trail.
  • endSize: The end size of the trail.
  • length: The length of the trail.
  • material: The material to use. Invalid materials will have no effect.

Return value:

    (Entity) The created sprite trail entity.
Entity:toLocal( value )
Converts an angle or vector in world space to entity local space.

Environment:

Shared

Parameters:

  • (Angle | Vector) value: World space angle or vector.

Return value:

    (Angle | Vector) The angle or vector corresponding to the given world value in local space.
Entity:toWorld( value )
Converts an angle or vector in entity local space to world space.

Environment:

Shared

Parameters:

  • (Angle | Vector) value: Local space angle or vector.

Return value:

    (Angle | Vector) The angle or vector corresponding to the given local value in world space.
Entity:unconstrain( type )
Removes constraints from the given entity.

Deprecated: Use constraint.removeConstraints( entity, type ) or constraint.removeAll( entity ).

Environment:

Server

Parameters:

  • (string?) type: Optional type of constraint to remove. No type will remove all constraints.
Entity:unlink()
Unlinks the given entity from its resource node.

Environment:

Server

Return value:

    (boolean) True if succeeded, false and a failure reason otherwise.
Entity:up()
Gets the entity's upward direction vector.

Environment:

Shared
Entity:vel()
Returns the velocity of the entity

Environment:

Shared

Return value:

    (Vector) The velocity vector
Entity:waterLevel()
Returns the entity's water level.

Environment:

Shared

Return value:

    (number) 0 is not in water, 1 is slightly inside, 2 is mostly inside and 3 is completely inside.
Entity:weldTo( ent, bone1, bone2, forceLimit, noCollide, deleteEnt1OnBreak )
Creates a weld constraint between two entities.

Deprecated: Use constraint.weld

Environment:

Server

Parameters:

  • (Entity) ent: Second entity.
  • (number?) bone1: Bone on the first entity, defaults to 0.
  • (number?) bone2: Bone on the second entity, defaults to 0.
  • forceLimit:
  • (boolean?) noCollide: Limit on the weld before it breaks, default is 0 (no limit).
  • (boolean?) deleteEnt1OnBreak: Sets whether to delete the first entity when the weld breaks.

Valid XHTML 1.0!