<?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%2Fpc_head%28%29</id>
	<title>Manual:DIL Manual/pc 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%2Fpc_head%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/pc_head()&amp;action=history"/>
	<updated>2026-11-22T21:36:56Z</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/pc_head()&amp;diff=2963&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/pc_head()&amp;diff=2963&amp;oldid=prev"/>
		<updated>2026-11-14T23:15:23Z</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;= pc_head() =&lt;br /&gt;
'''Function''' (unitptr). The first player in the game's global unit list.&lt;br /&gt;
&lt;br /&gt;
 pc_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;pc_head()&amp;lt;/code&amp;gt; returns the first player, the one who entered the game last, or null when no players are on. Follow &amp;lt;code&amp;gt;gnext&amp;lt;/code&amp;gt; while the unit is a player to visit everyone online.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Unitptr: the first player, or null if no player is in the game.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Players are at the very start of the list, so when someone is on, &amp;lt;code&amp;gt;pc_head()&amp;lt;/code&amp;gt; is the same unit as &amp;lt;code&amp;gt;ghead()&amp;lt;/code&amp;gt;. The difference is that &amp;lt;code&amp;gt;pc_head()&amp;lt;/code&amp;gt; gives null instead of an NPC when nobody is on.&lt;br /&gt;
* Stop at the first unit that isn't a player: &amp;lt;code&amp;gt;while (pc.type == UNIT_ST_PC)&amp;lt;/code&amp;gt;. When &amp;lt;code&amp;gt;pc_head()&amp;lt;/code&amp;gt; is null, &amp;lt;code&amp;gt;pc.type&amp;lt;/code&amp;gt; fails and the loop doesn't run.&lt;br /&gt;
* Don't wait inside the loop: unit variables are cleared at every wait unless &amp;lt;code&amp;gt;secure&amp;lt;/code&amp;gt;d, so the walk would lose its place.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin integer players_on();&lt;br /&gt;
var&lt;br /&gt;
   pc : unitptr;&lt;br /&gt;
   n : integer;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   pc := pc_head();&lt;br /&gt;
   while (pc.type == UNIT_ST_PC)&lt;br /&gt;
   {&lt;br /&gt;
      n := n + 1;&lt;br /&gt;
      pc := pc.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 players in the game; competition.zon and wiz.zon walk the players the same way.&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/gnext|gnext]]&lt;br /&gt;
* [[Manual:DIL Manual/findunit()|findunit()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>