Manual:DIL Manual/priority
Jump to navigation
Jump to search
Contents
priority
Procedure. Keeps the unit's later programs from getting any event until nopriority.
priority;
After priority, the programs that come after this one on the same unit get nothing: no commands, no messages, no ticks. It lasts until this program calls nopriority or ends. It is used so that an NPC busy with something important (a fight, a walk to a rescue, a conversation) isn't pulled away by its other routines, such as random walking.
Notes
- A unit's programs come in
fnpriorder, lowest number first.prioritystops the programs with a higherfnpri(and those with the same one that come later); the ones before it go on as usual. - Only the programs on the same unit are affected. Programs on other units still get every event.
- It lasts through
waitandpause. The usual loop is:start: nopriority; wait(...); priority; ... goto start;. - Forgetting
nopriorityleaves the unit's later programs dead for as long as this program runs. - Ending the program (
quit, or the unit being destroyed) ends the priority too. - Calling it while it is already set changes nothing.
Example
dilbegin fnpri(FN_PRI_RESCUE) john_helpme();
code
{
heartbeat := PULSE_SEC * 10;
on_activation(self.position <= POSITION_SLEEPING, skip);
:start:
nopriority;
wait(SFB_COM, self.position == POSITION_FIGHTING);
priority;
exec("emote yells, 'John! Help!'", self);
sendto(activator.name, findsymbolic("john@haon_dor"));
while (self.position == POSITION_FIGHTING)
pause;
goto start;
}
dilend
Mary calls her husband for help when she is attacked, and her other programs wait until the fight is over. From haon_dor.zon.