Manual:DIL Manual/recall

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

recall

Keyword. Option of dilbegin: a saved program goes on where it stopped.

dilbegin recall name(...);

When a unit is saved with its programs (a player and what the player carries, when the player quits or is saved, and other units the game stores) and later loaded again, its programs are loaded with it. Without recall each program starts again from the first statement of code. With recall it goes on from the wait where it was, with its interrupt and on_activation settings still in force.

Notes

  • Variables are saved either way: integer, string, stringlist and intlist values come back with or without recall; unitptr, extraptr, zoneptr and cmdptr variables come back null, and secures are gone. A recalled program usually has to find its units again.
  • If the template's code has changed since the save, the program starts from the top anyway. If its variables have changed, they are emptied as well.
  • Only the position in the copied template itself is saved, not inside a template it called.
  • The option is stored in each copy when it is made. Adding or removing recall doesn't change copies that are already saved on players' things.
  • It only matters for units that are saved. On an NPC or a room that is never saved it does nothing.

Example

dilbegin recall hunt_timer(minutes : integer);
var
   kills : integer;
code
{
   heartbeat := PULSE_SEC * 60;
   sendtext("The hunt begins: you have " + itoa(minutes) + " minutes.<br/>", self);
   while (minutes > 0)
   {
      wait(SFB_DEAD | SFB_TICK, command(CMD_AUTO_TICK) or
           (command(CMD_AUTO_DEATH) and (activator == self.fighting)));
      if (command(CMD_AUTO_TICK))
         minutes := minutes - 1;
      else
         kills := kills + 1;
   }
   sendtext("The hunt is over: " + itoa(kills) + " kills.<br/>", self);
   quit;
}
dilend

Copied onto a player, it counts down the minutes and the kills. If the player quits and comes back, it goes on counting; without recall it would announce a new hunt (with the minutes and kills it had). Adapted from spree_f in bounty.zon.

See also