Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "find"
From Quake Wiki
m (→Example) |
|||
Line 17: | Line 17: | ||
== Example == | == Example == | ||
// This finds every target the entity has and sets their health to 200 | // This finds every target the entity has and sets their health to 200 | ||
− | entity it = find(world, targetname, self.target); | + | for (entity it = find(world, targetname, self.target); it; it = find(it, targetname, self.target)) |
− | |||
− | |||
it.health = 200; | it.health = 200; | ||
− | |||
− | |||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Latest revision as of 15:47, 31 July 2023
entity find(entity start, .string fieldName, string fieldValue)
Contents
Usage[edit]
Searches through the entity list, finding the first entity whose field name has the passed field value. Can be used to iterate through every entity in the map to find specific ones e.g. an entity's targets when it activates.
Parameters[edit]
- start
- The entity to start from in the list, exclusive. Passing world will start from the very first entity.
- fieldName
- The name of the string field on the entity to check. This is a symbol e.g. if you wanted to check an entity's targetname field, you would pass
targetname
.
- fieldValue
- The value that the entity's field must be set to in order to be considered a match.
Return[edit]
The first entity found starting after start whose field has the passed value.
Example[edit]
// This finds every target the entity has and sets their health to 200 for (entity it = find(world, targetname, self.target); it; it = find(it, targetname, self.target)) it.health = 200;