Description:
|
Searches a defined volume of 3d space for the specified objects within it and then can run function on each returned object.
Object category is either a single enum or a table of enums that defines the types of objects that will be searched for
Search volume is the defined 3d space that will be searched.
Handler is the function that will be run on each object that is found.
Any data is a variable that is passed to the handler function, it can be anything.
|
Examples:
|
The following example would populate the table "foundUnits" of any unit found within a sphere defined by the zone "town"
local foundUnits = {}
local sphere = trigger.misc.getZone('town')
local volS = {
id = world.VolumeType.SPHERE,
params = {
point = sphere.point,
radius = sphere.radius
}
}
local ifFound = function(foundItem, val)
foundUnits[#foundUnits + 1] = foundItem:getName()
return true
end
world.searchObjects(Object.Category.UNIT, volS, ifFound)
|