Difference between revisions of "Manual:DIL Manual/unsecure()"

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="bpunsec"></span>
+
= unsecure() =
−
unsecure ( u : unitptr )
+
'''Procedure.''' Ends the secure on a unit.
−
    u : Secured unit.
 
−
    result: Drop secure on a given unit.
 
  
−
---~---~---~---~---~---~---~---~---
+
  unsecure(u : unitptr)
−
<span id="bpunsec"></span>
 
−
  unsecure ( u : unitptr )
 
−
    u : Secured unit.
 
−
    result: Drop secure on a given unit.
 
  
−
---~---~---~---~---~---~---~---~---
+
Ends what [[Manual:DIL Manual/secure()|secure()]] started: the program no longer jumps to the label when <code>u</code> leaves, and from the next wake on the variables holding <code>u</code> are cleared like any other unit variable.
 +
 
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| u || unitptr || The secured unit.
 +
|}
 +
 
 +
== Notes ==
 +
* Call it before [[Manual:DIL Manual/destroy()|destroy()]] on a secured unit: destroying it fires the secure, the program jumps to the label at once and the rest is skipped.
 +
* It only ends the secures made in the current template call. A unit the caller secured stays secured.
 +
* Nothing happens when the unit isn't secured or the variable is null.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin token_taker();
 +
var
 +
  item : unitptr;
 +
code
 +
{
 +
  heartbeat := PULSE_SEC * 3;
 +
:start:
 +
  wait(SFB_DONE, command("give") and (target == self));
 +
  item := medium;
 +
  secure(item, gone);
 +
  pause;
 +
  act("$1n looks closely at $2n and nods.", A_ALWAYS, self, item, null, TO_ROOM);
 +
  unsecure(item);
 +
  destroy(item);
 +
  goto start;
 +
 
 +
:gone:
 +
  goto start;
 +
}
 +
dilend
 +
</pre>
 +
An NPC takes what it is given, looks at it, and destroys it. Without the <code>unsecure()</code>, <code>destroy()</code> would jump to <code>gone</code>, which here happens to be harmless, but skips anything written after it.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/secure()|secure()]]
 +
* [[Manual:DIL Manual/destroy()|destroy()]]

Latest revision as of 23:16, 14 November 2026

unsecure()

Procedure. Ends the secure on a unit.

unsecure(u : unitptr)

Ends what secure() started: the program no longer jumps to the label when u leaves, and from the next wake on the variables holding u are cleared like any other unit variable.

Parameters

Name Type Meaning
u unitptr The secured unit.

Notes

  • Call it before destroy() on a secured unit: destroying it fires the secure, the program jumps to the label at once and the rest is skipped.
  • It only ends the secures made in the current template call. A unit the caller secured stays secured.
  • Nothing happens when the unit isn't secured or the variable is null.

Example

dilbegin token_taker();
var
   item : unitptr;
code
{
   heartbeat := PULSE_SEC * 3;
:start:
   wait(SFB_DONE, command("give") and (target == self));
   item := medium;
   secure(item, gone);
   pause;
   act("$1n looks closely at $2n and nods.", A_ALWAYS, self, item, null, TO_ROOM);
   unsecure(item);
   destroy(item);
   goto start;

:gone:
   goto start;
}
dilend

An NPC takes what it is given, looks at it, and destroys it. Without the unsecure(), destroy() would jump to gone, which here happens to be harmless, but skips anything written after it.

See also