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

Difference between revisions of "nextent"

From Quake Wiki

 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Function: nextent ==
+
''entity'' '''nextent'''(''entity'' start)
  
entity nextent(entity e)
+
== Usage ==
 +
Gets the next entity in the list of all entities. Passing '''world''' will get the very first entity. Can be used to iterate through all entities and update them if <code>find()</code> is not general enough.
  
Returns entity that is just after e in the entity list.
+
=== Parameters ===
Useful to browse the list of entities, because it skips the undefined ones.
+
*''start''
Function: find
+
:The entity to start from, exclusive.
  
entity find (entity start, .string field, string match)
+
=== Return ===
 +
The next entity in the list, or '''world''' if at the end.
  
  start = begining of list to search (world, for the begining of list)
+
== Example ==
 
+
// This goes through every entity and disables their collision
  field = entity field that must be examined (ex: targetname)
+
for (entity it = nextent(world); it; it = nextent(it))
 
+
{
  match = value that must be matched (ex: other.target)
+
    if (it.solid == SOLID_BBOX || it.solid == SOLID_SLIDEBOX)
 
+
    {
returns the entity found, or world if no entity was found.
+
        it.solid = SOLID_NONE;
 
+
        setorigin(it, it.origin); // Relink them
 
+
    }
 
+
}
Searches the server entity list beginning at start, looking for an entity that has entity.field = match.
 
 
 
Example: find the first player entity
 
 
 
e = find( world, classname, "player");
 
 
 
Take care that field is a name of an entity field, without dot, and without quotes.
 

Latest revision as of 14:58, 1 August 2023

entity nextent(entity start)

Usage[edit]

Gets the next entity in the list of all entities. Passing world will get the very first entity. Can be used to iterate through all entities and update them if find() is not general enough.

Parameters[edit]

  • start
The entity to start from, exclusive.

Return[edit]

The next entity in the list, or world if at the end.

Example[edit]

// This goes through every entity and disables their collision
for (entity it = nextent(world); it; it = nextent(it))
{
    if (it.solid == SOLID_BBOX || it.solid == SOLID_SLIDEBOX)
    {
        it.solid = SOLID_NONE;
        setorigin(it, it.origin); // Relink them
    }
}