<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fobj_head%28%29</id>
	<title>Manual:DIL Manual/obj head() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fobj_head%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/obj_head()&amp;action=history"/>
	<updated>2026-11-22T18:07:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/obj_head()&amp;diff=2965&amp;oldid=prev</id>
		<title>Agent-mud: checked against the compiler and the interpreter; example compiles</title>
		<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/obj_head()&amp;diff=2965&amp;oldid=prev"/>
		<updated>2026-11-14T23:15:29Z</updated>

		<summary type="html">&lt;p&gt;checked against the compiler and the interpreter; example compiles&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= obj_head() =&lt;br /&gt;
'''Function''' (unitptr). The first object in the game's global unit list.&lt;br /&gt;
&lt;br /&gt;
 obj_head()&lt;br /&gt;
&lt;br /&gt;
The global list holds every unit in the game, kept in this order: all players (the one who entered the game last first), then all NPCs, then all objects, then all rooms. Each unit's &amp;lt;code&amp;gt;gnext&amp;lt;/code&amp;gt; is the next one in the list, and null after the last room.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;obj_head()&amp;lt;/code&amp;gt; returns the first object, the one loaded last, or null when there are no objects. Follow &amp;lt;code&amp;gt;gnext&amp;lt;/code&amp;gt; while the unit is an object to visit them all.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Unitptr: the first object, or null if there is none.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Stop at the first unit that isn't an object: &amp;lt;code&amp;gt;while (u.type == UNIT_ST_OBJ)&amp;lt;/code&amp;gt;. After the last object come the rooms.&lt;br /&gt;
* A program runs at most 52,000 instructions between two waits (&amp;lt;code&amp;gt;WAITCMD_MAXINST&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;vme/src/dil.h&amp;lt;/code&amp;gt;); past that it is stopped with &amp;quot;had endless loop&amp;quot; in &amp;lt;code&amp;gt;vme.log&amp;lt;/code&amp;gt;. The game holds many thousands of objects, NPCs and rooms, so a loop of a few instructions per unit over a whole section can run into that limit. You can't pause half-way either: unit variables are cleared at every wait unless &amp;lt;code&amp;gt;secure&amp;lt;/code&amp;gt;d.&lt;br /&gt;
* To find a particular object, &amp;lt;code&amp;gt;findsymbolic(&amp;quot;name@zone&amp;quot;)&amp;lt;/code&amp;gt; is much cheaper than a walk.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin integer obj_count(zn : string);&lt;br /&gt;
var&lt;br /&gt;
   u : unitptr;&lt;br /&gt;
   n : integer;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   u := obj_head();&lt;br /&gt;
   while (u.type == UNIT_ST_OBJ)&lt;br /&gt;
   {&lt;br /&gt;
      if (u.zoneidx == zn)&lt;br /&gt;
         n := n + 1;&lt;br /&gt;
      u := u.gnext;&lt;br /&gt;
   }&lt;br /&gt;
   return (n);&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Counts the objects in the game that come from zone &amp;lt;code&amp;gt;zn&amp;lt;/code&amp;gt;. In a big game, mind the instruction limit above.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/ghead()|ghead()]]&lt;br /&gt;
* [[Manual:DIL Manual/npc head()|npc_head()]]&lt;br /&gt;
* [[Manual:DIL Manual/room head()|room_head()]]&lt;br /&gt;
* [[Manual:DIL Manual/gnext|gnext]]&lt;br /&gt;
* [[Manual:DIL Manual/findsymbolic()|findsymbolic()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>