Manual:DIL Manual/zoneptr
Jump to navigation
Jump to search
Contents
zoneptr
Type. A pointer to a zone.
var z : zoneptr;
A zoneptr gives a program the facts about a zone: its name, title, creators, reset settings and size. zhead() is the first zone in the game, z.next the next one (null after the last), and findzone(name) finds one by name.
Fields
| Field | Type | Meaning |
|---|---|---|
| name | string | the zone's name, as in %zone
|
| title | string | the zone's title |
| creators | stringlist | its creators |
| next | zoneptr | the next zone |
| rooms, objs, npcs | unitptr | a unit of the zone's first room, object or NPC definition (in name order), or null when that one has none in the game |
| roomcount, objcount, npccount | integer | how many rooms, objects and NPCs the zone defines |
| resetmode, resettime | integer | its reset settings |
| access, loadlevel, payonly | integer | its access level, the level needed to load its things, and its pay-only setting |
| bonusband | integer | its treasure band, 0-7, or -1 (BONUS_NOT_APPLICABLE) when it has none |
| fname, notes, help | string | its file name, notes and help text |
Each field's page has the details.
Notes
- Zones stay for as long as the server runs, so zoneptr variables keep their value through waits. They are not saved with a unit: after loading they are null.
- A field of a null zoneptr fails; test
z == nullfirst. ==and!=compare two zoneptrs, or one withnull.- There is no
previousfield, though older pages listed one. - A unit's
zonefield is the name of the zone it is in, a string:findzone(u.zone)gives the zoneptr.
Example
dilbegin zoneptr get_zone(s : string);
var
zn : zoneptr;
code
{
zn := zhead();
while (zn != null)
{
if (zn.name == s)
break;
zn := zn.next;
}
return (zn);
}
dilend
dilbegin do_zinfo(arg : string);
external
zoneptr get_zone(s : string);
var
z : zoneptr;
code
{
z := get_zone(arg);
if (z == null)
{
sendtext("No zone called '" + arg + "'.<br/>", self);
quit;
}
sendtext(z.name + ": " + z.title + ", " + itoa(z.roomcount) + " rooms.<br/>", self);
quit;
}
dilend
A function that walks the zone list (as get_zone in commands.zon), and a command that uses it.