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

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the compiler and the interpreter; example compiles)
 
(corrected from the DIL keyword tests (T029-T043))
 
Line 7: Line 7:
  
 
== Notes ==
 
== Notes ==
 +
* A program read from a file (a room's or object's program when the zone boots, a unit brought back with [[Manual:DIL Manual/restore()|restore()]], a <code>recall</code> program on a player) doesn't run until the first event reaches it, and that event only takes it as far as its <code>wait()</code>: the event itself is lost. A room program waiting for a command misses the first one after a boot. Programs on units that <code>%reset</code> loads start at once and aren't affected.
 
* Variables are saved either way: integer, string, stringlist and intlist values come back with or without <code>recall</code>; unitptr, extraptr, zoneptr and cmdptr variables come back null, and secures are gone. A recalled program usually has to find its units again.
 
* Variables are saved either way: integer, string, stringlist and intlist values come back with or without <code>recall</code>; 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.
 
* 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.

Latest revision as of 07:21, 15 November 2026

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

  • A program read from a file (a room's or object's program when the zone boots, a unit brought back with restore(), a recall program on a player) doesn't run until the first event reaches it, and that event only takes it as far as its wait(): the event itself is lost. A room program waiting for a command misses the first one after a boot. Programs on units that %reset loads start at once and aren't affected.
  • 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