Manual:DIL Manual/hasfunc

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

hasfunc

Field (integer, read-only; units: all).

u.hasfunc : integer

TRUE when the unit has at least one program attached, a DIL program or one of the server's special functions; FALSE when it has none. A program asking about its own unit (self.hasfunc) always gets TRUE.

Notes

  • Read-only: vmc refuses an assignment ("Illegal lvalue").
  • It doesn't say which program: dilfind() looks for a given template.
  • On null it fails.

Example

dilbegin janitor();
var
   u : unitptr;
code
{
   heartbeat := PULSE_SEC * 60;
   :start:
   wait(SFB_TICK, TRUE);
   foreach (UNIT_ST_OBJ, u)
   {
      if ((u.outside == self.outside) and (u.objecttype == ITEM_TRASH) and (u.hasfunc == FALSE))
      {
         act("$1n sweeps up $2n.", A_SOMEONE, self, u, null, TO_ROOM);
         destroy(u);
      }
   }
   goto start;
}
dilend

A janitor that sweeps up trash in its room every minute, but leaves alone any item that runs a script.

See also