Difference between revisions of "Manual:DIL Manual/zoneptr"
Jump to navigation
Jump to search
(XML import) |
(bonusband) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | = 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. <code>zhead()</code> is the first zone in the game, <code>z.next</code> the next one (null after the last), and <code>findzone(name)</code> finds one by name. | ||
| − | + | == Fields == | |
| − | + | {| class="wikitable" | |
| − | + | ! Field !! Type !! Meaning | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/name|name]] || string || the zone's name, as in <code>%zone</code> | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/title|title]] || string || the zone's title | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/creators|creators]] || stringlist || its creators | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/next|next]] || zoneptr || the next zone | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/rooms|rooms]], [[Manual:DIL Manual/objs|objs]], [[Manual:DIL Manual/npcs|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 | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/roomcount|roomcount]], [[Manual:DIL Manual/objcount|objcount]], [[Manual:DIL Manual/npccount|npccount]] || integer || how many rooms, objects and NPCs the zone defines | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/resetmode|resetmode]], [[Manual:DIL Manual/resettime|resettime]] || integer || its reset settings | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/access|access]], [[Manual:DIL Manual/loadlevel|loadlevel]], [[Manual:DIL Manual/payonly|payonly]] || integer || its access level, the level needed to load its things, and its pay-only setting | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/bonusband|bonusband]] || integer || its treasure band, 0-7, or -1 (BONUS_NOT_APPLICABLE) when it has none | |
| − | + | |- | |
| − | + | | [[Manual:DIL Manual/fname|fname]], [[Manual:DIL Manual/notes|notes]], [[Manual:DIL Manual/help|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 <code>z == null</code> first. | |
| − | + | * <code>==</code> and <code>!=</code> compare two zoneptrs, or one with <code>null</code>. | |
| − | + | * There is no <code>previous</code> field, though older pages listed one. | |
| − | + | * A unit's <code>zone</code> field is the name of the zone it is in, a string: <code>findzone(u.zone)</code> gives the zoneptr. | |
| − | + | == Example == | |
| − | + | <pre> | |
| − | + | 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 | 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 | dilend | ||
| + | </pre> | ||
| + | A function that walks the zone list (as <code>get_zone</code> in commands.zon), and a command that uses it. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/zhead()|zhead()]] | |
| − | + | * [[Manual:DIL Manual/findzone()|findzone()]] | |
| − | + | * [[Manual:DIL Manual/zone|zone]] | |
| − | + | * [[Manual:DIL Manual/cmdptr|cmdptr]] | |
Latest revision as of 12:06, 20 November 2026
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.