Next Previous Contents

5. New Variable Types

5.1 The command pointer

Type: cmdptr

cmdptr fields

name

string - command name

type

integer - command type like social or skill or just command

level

integer - minimum level to use command

loglevel

integer - level of character that can see the log 0 for no logs

position

integer - minimum position to use command

next

cmdptr - pointer to the next cmdptr

previous

cmdptr - pointer to the previous cmdptr

The cmdptr can be used to search the command list or display all the commands. It is also now possible to sort the commands by type by defining your own command types and using the type field to sort on.

In order to get the first command in the list you use the following function:

Function: chead();

If you want to get a specific command then you use the following function:

Function: cmdptr := getcommand (s : string );

Example:



dilbegin cmdtst(arg : string);
var
  cmd : cmdptr;
  st : string;

code
{
   cmd := chead();
        while (cmd)
        { 
        st := cmd.name + " " + itoa(cmd.level) + " " + itoa(cmd.type) + " " +
              itoa(cmd.loglevel) + " " + itoa(cmd.position);
   act("CMD: $2t", A_ALWAYS, self, st, null, TO_CHAR);
        cmd := cmd.next;
        }
        
        cmd:=getcommand("kick");
        sendtext ("You must be "+itoa(cmd.level+" to use kick&n",self);
        
           quit;
}
dilend

5.2 The Integer List

Type: intlist

This variable type allows you to keep an ordered list of integers with out having to create a variable for each integer.

Example: Setting an intlist



myintlist:={1,5,9,2,8,5};
myintlist.[10]:=50;

If you set a index that is higher then the highest index every index in between will be set to zero. For example if you only have to values in the intlist and you set index value 10 to 50 all indexes between 2 and 10 will be set to 0.

Example: Using intlists


if (myintlist.[5]==5){
stuff
}

if (myintlist<myint){
stuff
}

i:=0;
ln:=length(myintlist);
while (i<ln){
myintlist.[i]:=i;
i:=i+1;
}

See Also Insert a string into a stringlist or integer into an intlist by index and Remove a string from a stringlist or integer from an intlist by index

5.3 The New extra pointer

The only change is that extra pointers now have a intlist attached. An example of defining one in a zone file would look like this.

Example:



extra {"old extra"}
"old extra descrs"


extra {"new extra"}{1,5,9}
"new extra descrs"

Both the old and new format works so you decide if you need the intlist. If you need a Dil can add an intlist later online.

Example:


 
 myext.vals.[5]:=6
 myext2.vals:={5,4,3,2,1};
 
 if ( myext.vals.[2]==5){
 do stuff
 }
 
 

5.4 The zone pointer

>WARNING: Please be very careful witht he Zoneptr variable type. Understand that Zoneptr's are not finished and could be unstable. All bugs that you find please report and make sure you send any suggestions to 'whistler@valhalla.com'

Type: zoneptr Zone Pointer Fields

next

unitptr - pointer to next zoneptr

previous

unitptr - pointer to previous zone

creators

stringlist - list of creators

name

string - zone name (%zone)

title

string - zone title (title "")

rooms

unitptr - pointer to the base room

objs

unitptr - pointer to the base objects of the zone

npcs

unitptr - pointer to base NPCs of the zone

resetmode

integer- reset mode of zone in 'values.h'

resettime

integer - the reset time of the zone

access

integer - the access level of the zone

loadlevel

integer - the loadlevel of the zone

payonly

integer - the paystatus of the zone

roomcount

integer - the number of rooms in a zone

objcount

integer - the numbner of objects in a zone

npccount

integer - the number of npcs/mobiles in a zone

fname

string - the filename of a zone

notes

string - the Zone Notes

help

string - the Zone Help

The 'zoneptr' works like a unitptr but it has some serious differences.

WARNING: The 'rooms', 'objs'', and 'npcs' fields point to the base unit not to a regular unitptr. This means if you change what these fields point to it will change all instances of that object that have not been loaded. Further more currently there is no protection so if you delete the object it could cause nasty things. We suggest you do not delete these units it could cause you serious head ache.

To get the first zoneptr in the global list of zones you use 'zhead'.

Example: zoneptr := zhead();

Zone list command



dilbegin zonelist (arg:string);
var
 z:zoneptr;
 buf:string;
code
{
z:=zhead();
while (z)
        {
        buf:="Name:  "+z.name+"&n";
        buf:=buf+"Filename:  "+z.fname+"&n";
        buf:=buf+"Creator:  "+z.creators.[0]+"&n";
           buf:=buf+"Notes:  &n"+z.notes+"&n&n";
           z:=z.next;
           }
           
           pagestring (buf,self);
           quit;
           }
           dilend
           
                   


Next Previous Contents