Dota 2 Workshop Tools/Scripting/API/CEntities.FindByClassnameWithin

From Valve Developer Community
Jump to navigation Jump to search
Note.pngNote: This page is automatically generated. Any changes may be overwritten

Function Description

handle FindByClassnameWithin(handle startFrom, string className, Vector origin, float maxRadius)

Find entities by class name within a radius. Pass nil to start an iteration, or reference to a previously found entity to continue a search

Parameters

Type Name Description Example
handle startFrom The last found unit, used to iterate through all units in area x/nil
string className The class of entity you are looking for "ent_dota_tree"
Vector origin The center of the area to search around keys.caster:GetAbsOrigin()
float maxRadius The radius in dota distance that you want to search 1000

Returns

handle - The handle to the found unit

Example

To search through and print out all entities of tree class in a given radius

local x = Entities:FindByClassnameWithin(nil, "ent_dota_tree", vars.caster:GetOrigin(), 1000) while x ~= nil do x = Entities:FindByClassnameWithin(x, "ent_dota_tree", vars.caster:GetOrigin(), 1000) print(x) end