Manual:DIL Manual/extraptr
Jump to navigation
Jump to search
Contents
extraptr
Type. A pointer to an extra description.
var exd : extraptr;
Extra descriptions are the texts a unit shows when looked at (look at sign), and DIL also uses them to store data on units: quest flags, counters, settings. look doesn't show an extra whose first name starts with $, so such names hold data. Each extra has these fields:
| Field | Type | Meaning |
|---|---|---|
| names | stringlist | the names it is found by |
| name | string | the first of the names |
| descr | string | its text (read and write) |
| vals | intlist | numbers stored with it |
| next | extraptr | the next extra on the same unit |
u.extra is the first extra of a unit. To find one by name, use "name" in u.extra or u.extra.["name"]; both give null when there is none.
Notes
- An extraptr variable is cleared at every wait (
wait,pause, a heartbeat), and it can't be secured. Look the extra up again after waiting. - A field of a null extraptr fails; test
exd == nullfirst. addextra()andsubextra()add and remove extras. An extra made with empty text is not added.- Extras themselves are saved with the unit; extraptr variables are not (they come back null).
Example
dilbegin visit_count();
var
pc : unitptr;
exd : extraptr;
code
{
:start:
wait(SFB_DONE, command(CMD_AUTO_ENTER) and (activator.type == UNIT_ST_PC)
and (activator.outside == self));
pc := activator;
exd := "$visits" in pc.extra;
if (exd == null)
{
addextra(pc.extra, {"$visits"}, "1");
sendtext("Welcome, stranger.<br/>", pc);
}
else
{
exd.descr := itoa(atoi(exd.descr) + 1);
sendtext("Welcome back, visit number " + exd.descr + ".<br/>", pc);
}
goto start;
}
dilend
On a room: counts each player's visits in a hidden extra on the player.