Manual:DIL Manual/next
Jump to navigation
Jump to search
Contents
next
Field (same type as the value it is taken from, read-only; on unitptr, extraptr, zoneptr and cmdptr).
u.next : unitptr e.next : extraptr z.next : zoneptr c.next : cmdptr
The next element of the list the value is in, or null after the last one:
- unitptr: the next unit in the same place (the next one in
u.outside.inside). Start with.insideof a room or container. - extraptr: the next extra description. Start with
.extraor.info. - zoneptr: the next zone, in alphabetical order of zone names. Start with zhead().
- cmdptr: the next command. Start with chead().
Notes
- On null it fails, except on an extraptr, where it gives null.
- It can't be assigned (vmc: "Illegal lvalue").
- For the global list of all units use gnext instead.
- A
whileloop that moves or kills units while it walks.nextgoes wrong: afterlink(u, elsewhere),u.nextis in the other place. Use foreach() for that. - A loop with
waitorpausein it loses its unitptr and extraptr variables at every wake.
Example
dilbegin count_items();
var
u : unitptr;
n : integer;
code
{
u := self.outside.inside;
while (u)
{
if (u.type == UNIT_ST_OBJ)
n := n + 1;
u := u.next;
}
act("There are " + itoa(n) + " things lying here.", A_ALWAYS, self, null, null, TO_CHAR);
quit;
}
dilend
Counts the objects in the room.