Manual:DIL Manual/findzone()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:18, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

findzone()

Function (zoneptr). Finds a zone by its name.

findzone(zname : string) : zoneptr

Returns the zone called zname, the name after %zone in its zone file (and after the @ in symbolic names). With the zone you can read its fields (name, roomcount, resetmode...) or reset it with zonereset().

Parameters

Name Type Meaning
zname string The zone's name, such as "midgaard", without an @.

Returns

The zone, or null when there is none of that name.

Notes

  • The name must match exactly, case included. Zone names are lower case, so findzone("Midgaard") is null; use tolower() on a name a player typed.
  • The zone field of a unit names the zone it is in now, so findzone(u.zone) is that zone.
  • To go through all zones, start at zhead().

Example

dilbegin do_zoneinfo(arg : string);
var
   z : zoneptr;
code
{
   z := findzone(tolower(getword(arg)));
   if (z == null)
   {
      sendtext("No such zone.<br/>", self);
      quit;
   }
   sendtext("Zone " + z.name + " has " + itoa(z.roomcount) + " rooms.<br/>", self);
   quit;
}
dilend

A command that looks a zone up by the name typed, as cmd_reset in commands.zon does.

See also