Manual:DIL Manual/inside

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:10, 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

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 while loop 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.

See also