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

Difference between revisions of "nextent"

From Quake Wiki

(New page: == Function: nextent == entity nextent(entity e) Returns entity that is just after e in the entity list. Useful to browse the list of entities, because it skips the undefined ones. Func...)
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
''entity'' '''nextent'''(''entity'' start)
  
== Function: nextent ==
+
== 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.
  
entity nextent(entity e)
+
=== Parameters ===
 +
*''start''
 +
:The entity to start from, exclusive.
  
Returns entity that is just after e in the entity list.
+
=== Return ===
Useful to browse the list of entities, because it skips the undefined ones.
+
The next entity in the list, or '''world''' if at the end.
Function: find
 
  
entity find (entity start, .string field, string match)
+
== Example ==
start = begining of list to search (world, for the begining of list)
+
// 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)
+
{
returns the entity found, or world if no entity was found.
+
    if (it.solid == SOLID_BBOX || it.solid == SOLID_SLIDEBOX)
 
+
    {
Searches the server entity list beginning at start, looking for an entity that has entity.field = match.
+
        it.solid = SOLID_NONE;
 
+
        setorigin(it, it.origin); // Relink them
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
    }
}