Difference between revisions of "Manual:DIL Manual/zoneptr"

From DikuMUD Wiki
Jump to navigation Jump to search
(bonusband)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
−
==zoneptr==
+
= zoneptr =
−
Type:  zoneptr
+
'''Type.''' A pointer to a zone.
  
−
A pointer to a zone.
+
var
 +
    z : zoneptr;
  
−
===Zone Pointer Fields===
+
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.
  
−
'''next'''
+
== Fields ==
−
    unitptr - pointer to next zoneptr
+
{| class="wikitable"
−
'''previous'''
+
! Field !! Type !! Meaning
−
    unitptr - pointer to previous zone
+
|-
−
'''creators'''
+
| [[Manual:DIL Manual/name|name]] || string || the zone's name, as in <code>%zone</code>
−
    stringlist - list of creators
+
|-
−
'''name'''
+
| [[Manual:DIL Manual/title|title]] || string || the zone's title
−
    string - zone name (%zone)
+
|-
−
'''title'''
+
| [[Manual:DIL Manual/creators|creators]] || stringlist || its creators
−
    string - zone title (title "")
+
|-
−
'''rooms'''
+
| [[Manual:DIL Manual/next|next]] || zoneptr || the next zone
−
    unitptr - pointer to the base room
+
|-
−
'''objs'''
+
| [[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
−
    unitptr - pointer to the base objects of the zone
+
|-
−
'''npcs'''
+
| [[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
−
    unitptr - pointer to base NPCs of the zone
+
|-
−
'''resetmode'''
+
| [[Manual:DIL Manual/resetmode|resetmode]], [[Manual:DIL Manual/resettime|resettime]] || integer || its reset settings
−
    integer- reset mode of zone in 'values.h'
+
|-
−
'''resettime'''
+
| [[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
−
    integer - the reset time of the zone
+
|-
−
'''access'''
+
| [[Manual:DIL Manual/bonusband|bonusband]] || integer || its treasure band, 0-7, or -1 (BONUS_NOT_APPLICABLE) when it has none
−
    integer - the access level of the zone
+
|-
−
  '''loadlevel'''
+
| [[Manual:DIL Manual/fname|fname]], [[Manual:DIL Manual/notes|notes]], [[Manual:DIL Manual/help|help]] || string || its file name, notes and help text
−
    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
 
  
 +
Each field's page has the details.
  
−
The 'zoneptr' works like a unitptr. To get the first zoneptr in the global list of zones you use 'zhead'.
+
== 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 ===
+
== Example ==
−
  dilbegin zonelist (arg:string);
+
<pre>
−
  var
+
dilbegin zoneptr get_zone(s : string);
−
    z:zoneptr;
+
var
−
    buf:string;
+
  zn : zoneptr;
−
  code
+
code
−
  {
+
{
−
    z:=zhead();
+
  zn := zhead();
−
    while (z)
+
  while (zn != null)
−
    {
+
  {
−
      buf:="Name: "+z.name+"&amp;n";
+
      if (zn.name == s)
−
      buf:=buf+"Filename:  "+z.fname+"&amp;n";
+
        break;
−
      buf:=buf+"Creator: "+z.creators.[0]+"&amp;n";
+
      zn := zn.next;
−
      buf:=buf+"Notes:  &amp;n"+z.notes+"&amp;n&amp;n";
+
  }
−
      z:=z.next;
+
  return (zn);
−
    }
+
}
−
    pagestring (buf,self);
+
dilend
−
    quit;
+
 
−
}
+
dilbegin do_zinfo(arg : string);
−
dilend
+
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
 +
</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

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 == null first.
  • == and != compare two zoneptrs, or one with null.
  • There is no previous field, though older pages listed one.
  • A unit's zone field 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.

See also