Difference between revisions of "Manual:DIL Manual/priority"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(checked against the compiler and the interpreter; example compiles)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
= priority =
 +
'''Procedure.''' Keeps the unit's later programs from getting any event until <code>nopriority</code>.
  
 +
priority;
  
−
<span id="bppri"></span>
+
After <code>priority</code>, 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 <code>nopriority</code> 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.
−
priority
 
−
    result: Set until nopriority command. When set, no special routines
 
−
            "below" the current DIL program will be executed. This is used
 
−
            to make other special routines idle. See haon-dor.zon for an
 
−
            example.
 
  
−
---~---~---~---~---~---~---~---~---
+
== Notes ==
 +
* A unit's programs come in <code>fnpri</code> order, lowest number first. <code>priority</code> stops the programs with a higher <code>fnpri</code> (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 <code>wait</code> and <code>pause</code>. The usual loop is <code>:start: nopriority; wait(...); priority; ... goto start;</code>.
 +
* Forgetting <code>nopriority</code> leaves the unit's later programs dead for as long as this program runs.
 +
* Ending the program (<code>quit</code>, or the unit being destroyed) ends the priority too.
 +
* Calling it while it is already set changes nothing.
 +
 
 +
== Example ==
 +
<pre>
 +
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
 +
</pre>
 +
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 ==
 +
* [[Manual:DIL Manual/nopriority|nopriority]]
 +
* [[Manual:DIL Manual/fnpri|fnpri]]
 +
* [[Manual:DIL Manual/block|block]]
 +
* [[Manual:DIL Manual/wait()|wait()]]

Latest revision as of 23:23, 14 November 2026

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