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

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bpblock"></span>
+
= block =
−
block
+
'''Procedure.''' Stops the event that woke the program from going any further.
−
    result: Blocks any command issued by a player or mobile. Blocking a
 
−
            command prevents the command from being parsed by the
 
−
            interpreter. This is ideal if you need to make a routine
 
−
            which intercepts a command, reacts on it in a special way,
 
−
            and does not need the standard way of reacting.
 
  
−
---~---~---~---~---~---~---~---~---
+
  block;
−
<span id="bpblock"></span>
 
−
  block
 
−
    result: Blocks any command issued by a player or mobile. Blocking a
 
−
            command prevents the command from being parsed by the
 
−
            interpreter. This is ideal if you need to make a routine
 
−
            which intercepts a command, reacts on it in a special way,
 
−
            and does not need the standard way of reacting.
 
  
−
---~---~---~---~---~---~---~---~---
+
Most often used after <code>wait(SFB_CMD, ...)</code>: the command is not carried out, and no program after this one, on this unit or on the units around, gets it. The program then answers the command its own way.
 +
 
 +
== Notes ==
 +
* It applies to the event that woke the program this time. It can come anywhere before the program waits again (<code>wait</code>, <code>pause</code>), and it doesn't carry over to the next event.
 +
* What it stops depends on the event:
 +
** <code>SFB_CMD</code>: the command never runs.
 +
** <code>SFB_PRE</code>: the spell or the damage that is about to happen doesn't happen.
 +
** <code>SFB_DONE</code>, <code>SFB_MSG</code> and the others: the event has already happened; only the programs after this one don't hear of it.
 +
* A unit's programs get each event in <code>fnpri</code> order, lowest number first. A program that blocks must have a lower <code>fnpri</code> than the programs it should keep the command from.
 +
* <code>block</code> followed by <code>quit</code> still blocks.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin no_quit();
 +
code
 +
{
 +
  :start:
 +
  wait(SFB_CMD, command("quit") and (activator.level < IMMORTAL_LEVEL));
 +
  block;
 +
  act("For your safety you must withdraw from the arena to quit.",
 +
      A_ALWAYS, activator, null, null, TO_CHAR);
 +
  goto start;
 +
}
 +
dilend
 +
</pre>
 +
Keeps mortal players from quitting in the arena. Adapted from arena.zon.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/wait()|wait()]]
 +
* [[Manual:DIL Manual/command()|command()]]
 +
* [[Manual:DIL Manual/fnpri|fnpri]]
 +
* [[Manual:DIL Manual/priority|priority]]
 +
* [[Manual:DIL Manual/SFB CMD|SFB_CMD]]
 +
* [[Manual:DIL Manual/SFB PRE|SFB_PRE]]

Latest revision as of 23:23, 14 November 2026

block

Procedure. Stops the event that woke the program from going any further.

block;

Most often used after wait(SFB_CMD, ...): the command is not carried out, and no program after this one, on this unit or on the units around, gets it. The program then answers the command its own way.

Notes

  • It applies to the event that woke the program this time. It can come anywhere before the program waits again (wait, pause), and it doesn't carry over to the next event.
  • What it stops depends on the event:
    • SFB_CMD: the command never runs.
    • SFB_PRE: the spell or the damage that is about to happen doesn't happen.
    • SFB_DONE, SFB_MSG and the others: the event has already happened; only the programs after this one don't hear of it.
  • A unit's programs get each event in fnpri order, lowest number first. A program that blocks must have a lower fnpri than the programs it should keep the command from.
  • block followed by quit still blocks.

Example

dilbegin no_quit();
code
{
   :start:
   wait(SFB_CMD, command("quit") and (activator.level < IMMORTAL_LEVEL));
   block;
   act("For your safety you must withdraw from the arena to quit.",
       A_ALWAYS, activator, null, null, TO_CHAR);
   goto start;
}
dilend

Keeps mortal players from quitting in the arena. Adapted from arena.zon.

See also