<?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%2Fchead%28%29</id>
	<title>Manual:DIL Manual/chead() - 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%2Fchead%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/chead()&amp;action=history"/>
	<updated>2026-11-23T23:58:10Z</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/chead()&amp;diff=2971&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/chead()&amp;diff=2971&amp;oldid=prev"/>
		<updated>2026-11-14T23:15:47Z</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;= chead() =&lt;br /&gt;
'''Function''' (cmdptr). The first command in the game's command table.&lt;br /&gt;
&lt;br /&gt;
 chead()&lt;br /&gt;
&lt;br /&gt;
Returns the first entry of the command table, the commands loaded at boot from &amp;lt;code&amp;gt;vme/etc/commands.dat&amp;lt;/code&amp;gt; (built from &amp;lt;code&amp;gt;commands.def&amp;lt;/code&amp;gt;), in the order of that file. Each command's &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; field is the one after it, and null after the last, so a loop from &amp;lt;code&amp;gt;chead()&amp;lt;/code&amp;gt; visits every command, socials and skills included. Fields such as &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;level&amp;lt;/code&amp;gt; can then be read.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Cmdptr: the first command.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* &amp;lt;code&amp;gt;command_head()&amp;lt;/code&amp;gt; is another name for the same function.&lt;br /&gt;
* &amp;lt;code&amp;gt;cmd.type&amp;lt;/code&amp;gt; tells ordinary commands from socials and skills (&amp;lt;code&amp;gt;TYPE_SOCIAL&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TYPE_SKILL&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;vme/include/values.h&amp;lt;/code&amp;gt;); &amp;lt;code&amp;gt;cmd.level&amp;lt;/code&amp;gt; is the level needed to use it.&lt;br /&gt;
* &amp;lt;code&amp;gt;cmd.next&amp;lt;/code&amp;gt; on a null cmdptr fails; test the pointer in the loop: &amp;lt;code&amp;gt;while (cmd)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin list_cmds(pc : unitptr);&lt;br /&gt;
var&lt;br /&gt;
   cmd : cmdptr;&lt;br /&gt;
   sl : stringlist;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   cmd := chead();&lt;br /&gt;
   while (cmd)&lt;br /&gt;
   {&lt;br /&gt;
      if ((cmd.level &amp;lt;= pc.level) and (cmd.type != TYPE_SOCIAL) and (cmd.type != TYPE_SKILL))&lt;br /&gt;
         addstring(sl, cmd.name);&lt;br /&gt;
      cmd := cmd.next;&lt;br /&gt;
   }&lt;br /&gt;
   sendtext(itoa(length(sl)) + &amp;quot; commands.&amp;lt;br/&amp;gt;&amp;quot;, pc);&lt;br /&gt;
   return;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Collects the commands a character may use, leaving out socials and skills, as the &amp;lt;code&amp;gt;commands&amp;lt;/code&amp;gt; command in commands.zon does.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/command head()|command_head()]]&lt;br /&gt;
* [[Manual:DIL Manual/cmdptr|cmdptr]]&lt;br /&gt;
* [[Manual:DIL Manual/next|next]]&lt;br /&gt;
* [[Manual:DIL Manual/command()|command()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>