Manual:DIL Manual/clear()
Jump to navigation
Jump to search
clear()
Procedure. Removes an interrupt set up with interrupt().
clear(i : integer);
Removes interrupt number i of the running template, the number that interrupt() returned. The program then no longer jumps to that interrupt's label.
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | The interrupt's number, as returned by interrupt().
|
Notes
- A number that isn't in use does nothing.
- The interrupts after the cleared one move down a place, so their numbers change: interrupt 2 becomes 1 after
clear(1). Clearing several, clear the highest number first, or set them up again. - It only reaches the interrupts of the template that runs
clear, not those of a template that called it. - Running the same
interrupt()statement again replaces the old one, so there is no need to clear it first.
Example
dilbegin guard_post();
var
i : integer;
code
{
heartbeat := PULSE_SEC * 30;
i := interrupt(SFB_MSG, argument == "stand down", relieved);
:loop:
wait(SFB_TICK, TRUE);
act("$1n looks around watchfully.", A_SOMEONE, self, null, null, TO_ROOM);
goto loop;
:relieved:
clear(i);
act("$1n relaxes and sits down.", A_SOMEONE, self, null, null, TO_ROOM);
pause;
act("$1n stands up and goes back to the post.", A_SOMEONE, self, null, null, TO_ROOM);
i := interrupt(SFB_MSG, argument == "stand down", relieved);
goto loop;
}
dilend
An NPC on guard that takes a break when told "stand down"; while it rests, the message does nothing.