e2 docs entity - wiremod/wire GitHub Wiki

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:model()

Gets the model of an entity (5 ops)

Entity = Entity:owner()

Gets the owner of an entity (5 ops)

Table = Entity:keyvalues()

Returns the keyvalue table of an entity (20 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)

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: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)

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 (5 ops)

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

StartSize, EndSize, Length, Material, Color (RGB), Alpha. Adds a trail to E with the specified attributes (30 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. Adds a trail to E with the specified attributes (30 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)