Garry's Mod Wiki

ents.FindByClass

ents.FindByClass

table ents.FindByClass( string class )

Description

Gets all entities with the given class, supports wildcards. This works internally by iterating over ents.GetAll. Even if internally ents.GetAll is used, It is faster to use ents.FindByClass than ents.GetAll with a single class comparison.

Asterisks (*) are the only wildcard supported.

Arguments

1 string class
The class of the entities to find.

Returns

1 table
A table containing all found entities

Example

Prints the location of every prop on the map.

for k, v in ipairs( ents.FindByClass( "prop_*" ) ) do print( v:GetPos() ) end
Output: The location of each prop on the map. In gm_construct, the output might be as follows:

-2936.288818 -1376.545532 -73.852913 -2943.928467 -1375.800171 -84.964996 -2932.637695 -1288.051636 -76.791924 -2064.000000 -183.000000 -179.216003 -2384.000000 -183.000000 -179.216003 -2704.000000 -183.000000 -179.216003 -1744.000000 -183.000000 -179.216003 -1424.000000 -183.000000 -179.216003 -3019.895020 -1095.824829 -78.900757

Special Pages


Wikis

?

Render Time: 82ms

DB GetPage 53
Generate Html 4
SaveChanges (1) 16
Render Body 0
Render Sidebar 7