Manual:DIL Manual/findzone()
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; usetolower()on a name a player typed. - The
zonefield of a unit names the zone it is in now, sofindzone(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.