Skip to content
DerelictDrone edited this page May 28, 2025 · 7 revisions

Jump to table of contents

Entity

Entity = entity(Number Id)

Gets the entity associated with the id (5 ops)

Number = Entity:id()

Gets the numeric id of an entity (5 ops)

Number = Entity:creationID()

(5 ops)

Number = Entity:creationTime()

Returns the time the entity was created on, relative to curtime. (5 ops)

Entity = noentity()

Returns an invalid entity (5 ops)

Entity = world()

Returns the world entity (5 ops)

String = Entity:name()

Gets the name of a player (5 ops)

String = Entity:type()

Gets the class of an entity (5 ops)

String = Entity:getClass()

(5 ops)

String = Entity:model()

Gets the model of an entity (5 ops)

Entity = Entity:owner()

Gets the owner of an entity (5 ops)

Array = entities()

Returns an array containing all entities on the map (100 ops)

Table = Entity:keyvalues()

Returns the keyvalue table of an entity (20 ops)

Number = Entity:setEditProperty(String Key, String Value)

Sets an editable property to the string-encoded value. Returns 1 if it succeeded (20 ops)

String = Entity:getEditProperty(String Key)

Returns a string encoding of the editable property (20 ops)

Table = Entity:getEditData()

Returns a look-up table of editable values on an editable entity (30 ops)

Number = Entity:isEditable()

Returns 1 if the entity has editable properties (1 ops)

Vector = Entity:pos()

Gets the position of the entity (5 ops)

Vector = Entity:forward()

Gets the forward direction of the entity 2) (5 ops)

Vector = Entity:right()

Gets the right direction of the entity (5 ops)

Vector = Entity:up()

Gets the up direction of the entity (5 ops)

Vector = Entity:vel()

Gets the velocity of the entity (5 ops)

Vector = Entity:velL()

Gets the local velocity of the entity (5 ops)

Vector = Entity:velAtPoint(Vector Worldposition)

Gets the world velocity of a point in world coordinates attached to the entity (5 ops)

Angle = Entity:angVel()

Gets the angular velocity of the entity (5 ops)

Vector = Entity:angVelVector()

Returns rotation axis, velocity and direction given as the vector's direction, magnitude and sense (5 ops)

Vector = sunDirection()

Returns the vector direction that points towards the sun (5 ops)

Vector = Entity:toWorld(Vector Localposition)

Transforms from a vector local to E to a world vector (15 ops)

Vector = Entity:toLocal(Vector Worldposition)

Transforms from a world vector to a vector local to E (15 ops)

Vector = Entity:toWorldAxis(Vector Localaxis)

Transforms an axis local to E to a global axis (15 ops)

Vector = Entity:toLocalAxis(Vector Worldaxis)

Transforms a world axis to an axis local to E (15 ops)

Angle = Entity:toWorld(Angle Localangle)

Transforms from an angle local to E to a world angle (15 ops)

Angle = Entity:toLocal(Angle Worldangle)

Transforms from a world angle to an angle local to E (15 ops)

Number = Entity:health()

Gets the health of the entity (5 ops)

Number = Entity:maxHealth()

Gets the max health of the entity (5 ops)

Number = Entity:radius()

Gets the size of the object (not precisely, but useful) (5 ops)

Number = Entity:bearing(Vector Pos)

Gets the bearing from the entity to the vector (15 ops)

Number = Entity:elevation(Vector Pos)

Gets the elevation from the entity to the vector (15 ops)

Angle = Entity:heading(Vector Pos)

Gets the elevation and bearing from the entity to the vector (15 ops)

Number = Entity:mass()

Gets the mass of the entity (10 ops)

Vector = Entity:massCenter()

Gets the Center of Mass of the entity (10 ops)

Vector = Entity:massCenterL()

Gets the center of mass as a local vector (10 ops)

setMass(Number Mass)

Sets the mass of the E2 chip (between 0.001 and 50,000) (10 ops)

Entity:setMass(Number Mass)

Sets the mass of the entity (between 0.001 and 50,000) (10 ops)

Number = Entity:volume()

Gets the volume of the entity (10 ops)

Number = Entity:surfaceArea()

Gets the surface area of the entity (10 ops)

Number = Entity:stress()

Gets the stress of the entity (10 ops)

Table = Entity:frictionSnapshot()

Returns current friction events of the entity as a table of tables [https://wiki.facepunch.com/gmod/PhysObj:GetFrictionSnapshot] (10 ops)

Number = Entity:isPlayer()

Is the entity a player? (10 ops)

Number = Entity:isNPC()

Is the entity a NPC? (10 ops)

Number = Entity:isNextBot()

Is the entity a NextBot? (10 ops)

Number = Entity:isRagdoll()

Is the entity a ragdoll? (10 ops)

Number = Entity:isVehicle()

Is the entity a vehicle? (10 ops)

Number = Entity:isWorld()

Is the entity the world? (10 ops)

Number = Entity:isOnGround()

Is the player/NPC resting on something? (10 ops)

Number = Entity:isUnderWater()

Is the entity under water? (10 ops)

Number = Entity:isValid()

Returns 1 if the entity is valid, 0 otherwise (10 ops)

Number = Entity:isValidPhysics()

Returns 1 if the entity has valid physics (players don't) (10 ops)

Angle = Entity:angles()

Gets the pitch, yaw and roll of the entity (10 ops)

String = Entity:getMaterial()

Returns the material of an entity (10 ops)

String = Entity:getSubMaterial(Number Index)

(10 ops)

Array = Entity:getMaterials()

(20 ops)

Entity:setMaterial(String Material)

Sets the material of an entity (10 ops)

Entity:setSubMaterial(Number Index, String Material)

(10 ops)

Number = Entity:getSkin()

Gets Es current skin number (10 ops)

Entity:setSkin(Number Skinindex)

Sets the skin of an entity (10 ops)

Number = Entity:getSkinCount()

Gets Es number of skins (10 ops)

Entity:setBodygroup(Number Bgrp_id, Number Bgrp_subid)

Group ID, Group SubID Sets the bodygroups of the given entity (10 ops)

Number = Entity:getBodygroup(Number Bgrp_id)

(10 ops)

Number = Entity:getBodygroups(Number Bgrp_id)

Group ID Returns the number of bodygroups in the Group ID of the given entity (10 ops)

Number = Entity:isPlayerHolding()

Is the entity being held by a player? (10 ops)

Number = Entity:isOnFire()

Is the entity on fire? (10 ops)

Number = Entity:isWeapon()

Is the entity a weapon? (10 ops)

Number = Entity:isFrozen()

Is the entity frozen? (10 ops)

Number = Entity:isAsleep()

Is the entity asleep? (10 ops)

Number = Entity:isGravityEnabled()

Is gravity enabled for the entity? (10 ops)

Number = Entity:isPenetrating()

Is the entity penetrating another entity? (10 ops)

Entity:applyForce(Vector Force)

Applies force to the entity according to the given vector's direction and magnitude (30 ops)

Entity:applyOffsetForce(Vector Force, Vector Position)

Applies force to the entity according to the first vector from the location of the second (30 ops)

Entity:applyAngForce(Angle Angforce)

Applies torque to the entity according to the given angle (30 ops)

Entity:applyTorque(Vector Torque)

Applies torque to the entity according to the given vector, representing the torque axis, magnitude and direction (30 ops)

Vector = Entity:inertia()

Gets the principal components of the entity's inertia tensor in the form ( Ixx, Iyy, Izz ) (30 ops)

Entity:lockPod(Number Lock)

1 locks and 0 unlocks the vehicle (10 ops)

Entity:killPod()

Kills player in vehicle (10 ops)

Entity:ejectPod()

Ejects player in vehicle (10 ops)

Entity:podStripWeapons()

Strips player in vehicle (10 ops)

Vector = Entity:boxSize()

Gets the dimensions of the entity's bounding box as a vector (length, width, height) (10 ops)

Vector = Entity:boxCenter()

Gets the center of the entity's bounding box, as a local position vector (10 ops)

Vector = Entity:boxCenterW()

Same as using E:toWorld(E:boxCenter()), but since Lua is faster, this is more efficient (also shorter to write) (10 ops)

Vector = Entity:boxMax()

Gets the maximum local XYZ of the entity's bounding box (the "highest" corner), as a local position vector (10 ops)

Vector = Entity:boxMin()

Gets the minimum local XYZ of the entity's bounding box (the "lowest" corner), as a local position vector (10 ops)

Vector = Entity:aabbMin()

Returns the entity's (min) axis-aligned bounding box (10 ops)

Vector = Entity:aabbMax()

Returns the entity's (max) axis-aligned bounding box (10 ops)

Vector = Entity:aabbSize()

Returns the entity's axis-aligned bounding box size (10 ops)

Vector = Entity:aabbWorldMin()

Returns the rotated entity's min world-axis-aligned bounding box corner (10 ops)

Vector = Entity:aabbWorldMax()

Returns the rotated entity's max world-axis-aligned bounding box corner (10 ops)

Vector = Entity:aabbWorldSize()

Returns the rotated entity's world-axis-aligned bounding box size (10 ops)

Entity = Entity:driver()

Returns the driver of the vehicle if there is one, nil otherwise (5 ops)

Entity = Entity:passenger()

Returns the passenger of the vehicle if there is one, in single seat pods this will return the driver (5 ops)

String = Entity:toString()

Converts entity to string (5 ops)

String = toString(Entity Ent)

Converts entity to string (5 ops)

Entity:removeTrails()

Removes the trail from E (50 ops)

Entity:setTrails(Number Startsize, Number Endsize, Number Length, String Material, Vector Color, Number Alpha)

StartSize, EndSize, Length, Material, Color (RGB), Alpha. Sets entity's trails with the specified attributes (75 ops)

Entity:setTrails(Number Startsize, Number Endsize, Number Length, String Material, Vector4 Color)

StartSize, EndSize, Length, Material, Color (RGBA). Sets entity's trails with the specified attributes (75 ops)

Entity:setTrails(Number Startsize, Number Endsize, Number Length, String Material)

StartSize, EndSize, Length, Material. Sets entity's trails with the specified attributes (75 ops)

Entity:setTrails(Number Startsize, Number Endsize, Number Length, String Material, Vector Color, Number Alpha, Number Attachmentid, Number Additive)

StartSize, EndSize, Length, Material, Color (RGB), Alpha, AttachmentID, Additive. Sets entity's trails with the specified attributes (75 ops)

Number = trailsLeft()

Returns how many more entities can have trails (2 ops)

Number = trailsCount()

Returns how many entities currently have trails (2 ops)

Number = trailsMax()

Returns the maximum amount of entities that can have trails at the same time (Beware, the limit is shared between different chips!) (1 ops)

Number = Entity:lookupAttachment(String Attachmentname)

Returns Es attachment ID associated with attachmentName (15 ops)

Vector = Entity:attachmentPos(Number Attachmentid)

Returns Es attachment position associated with attachmentID (15 ops)

Angle = Entity:attachmentAng(Number Attachmentid)

Returns Es attachment angle associated with attachmentID (15 ops)

Vector = Entity:attachmentPos(String Attachmentname)

Same as E:attachmentPos(E:lookupAttachment(attachmentName)) (15 ops)

Angle = Entity:attachmentAng(String Attachmentname)

Same as E:attachmentAng(E:lookupAttachment(attachmentName)) (15 ops)

Array = Entity:attachments()

Returns array of attachment names of the entity (20 ops)

Vector = Entity:nearestPoint(Vector Point)

Returns the closest point on the edge of the entity's bounding box to the given vector (15 ops)

Entity:ignite()

Ignites an entity for 360 seconds (same as C menu). Requires wire_expression2_entity_ignite_enabled (15 ops)

Entity:ignite(Number Length)

Ignites an entity for the given length in seconds. Requires wire_expression2_entity_ignite_enabled (15 ops)

Entity:ignite(Number Length, Number Radius)

Creates a fire at an entity with given radius and length in seconds. Requires wire_expression2_entity_ignite_enabled (15 ops)

Entity:extinguish()

Extinguishes an entity granted you have permission. Does not work inside of entityDamage event if the attacker is the fire itself (15 ops)

Number = Entity:getCollisionGroup()

Returns the collision group of the entity (15 ops)

Entity:setCollisionGroup(Number Group)

Sets the collision group of the entity. Does not work on players. Use one of the _COLLISION_GROUP constants (15 ops)

Entity:noCollideAll(Number State)

(15 ops)

Array = Entity:getFlexBounds(Number Flex)

(5 ops)

Number = Entity:getFlexCount()

Gets the number of flexes on the entity (5 ops)

Number = Entity:getFlexID(String Flex)

Gets the flex ID of the given name or -1 if it doesn't exist (5 ops)

Number = Entity:getFlexScale()

Gets the flex scale of the entity (5 ops)

String = Entity:getFlexName(Number Id)

Gets the name of the flex (5 ops)

Number = Entity:getFlexWeight(Number Flex)

(5 ops)

Number = Entity:hasFlexes()

Returns 1 if the entity has flexes (5 ops)

Array = Entity:getFlexBounds(String Flex)

(15 ops)

Number = Entity:getFlexWeight(String Flex)

(15 ops)

Array = Entity:getFlexes()

Gets a 0-indexed array of all flexes and their names (50 ops)

Number = Entity:getModelBoneCount()

Gets the number of bones on the entity's model. Note these are different from E2 bones (5 ops)

Number = Entity:getModelBoneIndex(String Bone_name)

Gets the bone index of the given name or -1 if it doesn't exist (5 ops)

Number = Entity:getModelBoneName(Number Bone_index)

Gets the name of the bone (5 ops)

Array = Entity:getModelBones()

Gets a 0-indexed array of all bones and their names. Note these are different from E2 bones (50 ops)

Expression 2 ⚙️

Getting Started 🕊

Guides (In learning order) 🎓

Tools 🛠️

Click To Expand

Advanced

Beacon 💡

Control 🎛️

Data 💿

Detection 👀

Display 💻

Render 🖌

I/O 🔌

Physics 🚀

Utilities 🛠️

RFID 💳

Wireless 🛜

Gates 🚥

Click To Expand

TBD

Extras 🔭

Clone this wiki locally