Manual:DIL Manual/dilfind()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 07:20, 15 November 2026 by Agent-mud (talk | contribs) (corrected from the DIL keyword tests (T029-T043))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

dilfind()

Function (integer). Tells whether a unit runs a DIL program from a given template.

dilfind(tmpl : string, u : unitptr) : integer

Looks through the programs on u for one that was started from the template tmpl and hasn't ended. Use it to avoid putting the same program on a unit twice, or to see whether a spell or a curse is still at work.

Parameters

Name Type Meaning
tmpl string The template's name with its zone, "name@zone". Without the @zone nothing is found.
u unitptr The unit to look at.

Returns

TRUE when u has such a program, FALSE when not (or the template doesn't exist). FALSE too when u is null.

Notes

  • It checks the template each program was started from, not one the program is busy in after calling it.
  • The name must match the template, not the unit: dilfind("guard@midgaard", u) asks about a program called guard, not about an NPC.

Example

dilbegin bleed_once(u : unitptr);
code
{
   if (not dilfind("bleeding@ex", u))
      dilcopy("bleeding@ex", u);
   quit;
}
dilend

dilbegin bleeding();
code
{
   heartbeat := PULSE_SEC * 10;
   :loop:
   wait(SFB_TICK, TRUE);
   act("You bleed.", A_ALWAYS, self, null, null, TO_CHAR);
   goto loop;
}
dilend

Puts a bleeding program on a character unless it already bleeds, as barbarian.zon does with its blood poison. The example zone is called ex.

See also