Manual:DIL Manual/priority

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

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 fnpri order, lowest number first. priority stops the programs with a higher fnpri (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 wait and pause. The usual loop is :start: nopriority; wait(...); priority; ... goto start;.
  • Forgetting nopriority leaves 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.

See also