Library find
Find library. Finds entities using various criteria.
Functions
| all( filter ) | Finds all entitites. |
| allPlayers( filter ) | Finds all players (including bots). |
| alongRay( startPos, endPos, mins, maxs, filter ) | Finds all entities intersecting the given ray. |
| byClass( class, filter ) | Finds entities by class name. |
| byIndex( index ) | Finds an entity by its index. |
| byModel( modelPath, filter ) | Finds entities by their model path. |
| inBox( mins, maxs, filter ) | Finds entities contained within an axis-aligned box in world space. |
| inCone( pos, dir, distance, cosAngle, filter ) | Finds entities in a cone. |
| inSphere( centre, radius, filter ) | Finds entities in a sphere. |
| playerByName( name ) | Finds a player by name. |
Functions
- find.all( filter )
-
Finds all entitites.
Environment:
SharedParameters:
-
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.allPlayers( filter )
-
Finds all players (including bots).
Environment:
SharedParameters:
-
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.alongRay( startPos, endPos, mins, maxs, filter )
-
Finds all entities intersecting the given ray.
Environment:
SharedParameters:
-
(Vector) startPos: The starting position of the ray. -
(Vector) endPos: The end position of the ray. -
(Vector?) mins: (Optional) If provided, sets the mins corner of an axis-aligned box that will be used to test entities along the ray. -
(Vector?) maxs: (Optional) Sets the maxs corner of the axis-aligned box to test entities with (assuming mins was provided). -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.byClass( class, filter )
-
Finds entities by class name. The provided class name can contain wildcards ('*') to match zero or more characters.
Environment:
SharedParameters:
-
(string) class: The class name, optionally with wildcards. -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Usage:
-- Find all entities whose class name starts with "prop_" local Props = find.byClass( "prop_*" ) -- Find all entities whose class name is exactly "prop_physics" local PhysicsProps = find.byClass( "prop_physics" )
Return value:
(tableAn array of found entities.) -
- find.byIndex( index )
-
Finds an entity by its index.
Environment:
SharedParameters:
-
(number) index: The entity index.
Return value:
(Entity | nil)The matching entity if it exists, or nil otherwise. -
- find.byModel( modelPath, filter )
-
Finds entities by their model path. The provided model path can contain wildcards ('*') to match zero or more characters.
Environment:
SharedParameters:
-
(string) modelPath: The model file to search for, optionally with wildcards. -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Usage:
-- Find all entities whose model path starts with "models/props_borealis" local Ents = find.byModel( "models/props_borealis/*" ) -- Find all entities whose model is exactly "models/props_borealis/bluebarrel001.mdl" local Barrels = find.byModel( "models/props_borealis/bluebarrel001.mdl" )
Return value:
(tableAn array of found entities.) -
- find.inBox( mins, maxs, filter )
-
Finds entities contained within an axis-aligned box in world space. Note that any entity that the box intersects is returned, even if that entity is not fully within the box.
Environment:
SharedParameters:
-
(Vector) mins: Minimum extents of the box to search within (world space). -
(Vector) maxs: Maximum extents of the box to search within (world space). -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.inCone( pos, dir, distance, cosAngle, filter )
-
Finds entities in a cone.
Environment:
SharedParameters:
-
(Vector) pos: The cone position. -
(Vector) dir: The direction to project the cone. -
(number) distance: The length to project the cone. -
(number) cosAngle: The cosine of the angle of the cone (between 0 and 1, where 1 is 0° and 0 is 180°). -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.inSphere( centre, radius, filter )
-
Finds entities in a sphere.
Environment:
SharedParameters:
-
(Vector) centre: Centre of the sphere. -
(number) radius: Sphere radius. -
(function?) filter: (Optional) Function to filter results, passed each entity that was found. Return true to include the entity, false to skip it.
Return value:
(tableAn array of found entities.) -
- find.playerByName( name )
-
Finds a player by name.
Environment:
SharedParameters:
-
(string) name: Name to find.
Return value:
(Player | nil)The best matching player found for the given name, or nil if no player matched. -