Difference between revisions of "Manual:DIL Manual/dilfind()"
Jump to navigation
Jump to search
(checked against the compiler and the interpreter; example compiles) |
(corrected from the DIL keyword tests (T029-T043)) |
||
| Line 16: | Line 16: | ||
== Returns == | == Returns == | ||
| − | TRUE when <code>u</code> has such a program, FALSE when not (or the template doesn't exist). | + | TRUE when <code>u</code> has such a program, FALSE when not (or the template doesn't exist). FALSE too when <code>u</code> is null. |
== Notes == | == Notes == | ||
Latest revision as of 07:20, 15 November 2026
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.