Manual:DIL Manual/chead()
Jump to navigation
Jump to search
Contents
chead()
Function (cmdptr). The first command in the game's command table.
chead()
Returns the first entry of the command table, the commands loaded at boot from vme/etc/commands.dat (built from commands.def), in the order of that file. Each command's next field is the one after it, and null after the last, so a loop from chead() visits every command, socials and skills included. Fields such as name, type and level can then be read.
Returns
Cmdptr: the first command.
Notes
command_head()is another name for the same function.cmd.typetells ordinary commands from socials and skills (TYPE_SOCIAL,TYPE_SKILLinvme/include/values.h);cmd.levelis the level needed to use it.cmd.nexton a null cmdptr fails; test the pointer in the loop:while (cmd).
Example
dilbegin list_cmds(pc : unitptr);
var
cmd : cmdptr;
sl : stringlist;
code
{
cmd := chead();
while (cmd)
{
if ((cmd.level <= pc.level) and (cmd.type != TYPE_SOCIAL) and (cmd.type != TYPE_SKILL))
addstring(sl, cmd.name);
cmd := cmd.next;
}
sendtext(itoa(length(sl)) + " commands.<br/>", pc);
return;
}
dilend
Collects the commands a character may use, leaving out socials and skills, as the commands command in commands.zon does.