Manual:DIL Manual/inside
Jump to navigation
Jump to search
Contents
inside
Field (unitptr, read-only; units: all).
u.inside : unitptr
The first unit inside u, or null when it is empty. Follow next for the rest. For a room that is everything in it (characters, objects, rooms within it); for a character, everything it carries, worn and not worn; for a container, its contents.
Notes
- It can't be assigned (vmc: "Illegal lvalue"). Put units in with link().
- Only what is directly inside: the contents of a sack in a room are in
sack.inside, not in the room's list. - Worn objects are in the list too: test equip to tell them apart.
- A
whileloop that moves or destroys the units it walks goes wrong; use foreach() for that. - On null it fails.
Example
dilbegin integer pack_count(pc : unitptr);
var
u : unitptr;
n : integer;
code
{
u := pc.inside;
while (u)
{
if (not u.equip)
n := n + 1;
u := u.next;
}
return (n);
}
dilend
Counts what a character carries without wearing it.