Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Editing find

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''entity'' '''find'''(''entity'' start, ''.string'' fieldName, ''string'' fieldValue)
+
====Syntax:====
 +
<code>entity find(entity start, .string fld, string match)</code>
  
== Usage ==
+
Returns an entity who's entity variable matches <code>match</code> by searching through the edict list starting from <code>start</code>.
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:====
 +
:<code>start</code> - The entity to start searching from.  Use <code>world</code> to start from the top of the list.
 +
:<code>fld</code> - The field to check for matches.  Eg: .targetname
 +
:<code>match</code> - The values to check for.
 +
====Returns:====
 +
:Returns an entity that matches the criteria
  
=== Parameters ===
 
*''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 <code>targetname</code>.
 
*''fieldValue''
 
:The value that the entity's field must be set to in order to be considered a match.
 
 
=== Return ===
 
The first entity found starting after ''start'' whose field has the passed value.
 
 
== Example ==
 
// 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;
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)