Manual:DIL Manual/realtime

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

realtime

Variable (integer, read-only).

realtime : integer

The real time, in seconds since 1 January 1970 UTC: what time(NULL) gives in C.

Notes

  • It is the real clock: vme -w and wtimewarp don't move it, unlike mudhour and the other mud-time variables.
  • asctime() turns it into a readable date: asctime(realtime).
  • pc.birth is on the same clock, so realtime - pc.birth is a player's age in real seconds.
  • To keep a moment across reboots or on a unit, store itoa(realtime) in an extra and compare with atoi() later, as death.zon does with severed heads.
  • It is a 32-bit signed integer, so it overflows on 19 January 2038.

Example

dilbegin rot_away();
var
   e : extraptr;
code
{
   heartbeat := PULSE_SEC * 15;
   if (self.extra.["$made"] == null)
      addextra(self.extra, {"$made"}, itoa(realtime));

   :loop:
   pause;
   e := "$made" in self.extra;
   if (e == null)
      goto loop;
   if ((realtime - atoi(e.descr)) > 1800)
   {
      act("$1n rots away.", A_SOMEONE, self, null, null, TO_ROOM);
      destroy(self);
      quit;
   }
   goto loop;
}
dilend

An object that rots away half an hour (1800 real seconds) after it first ran, as the heads in death.zon. The extra is looked up again after each pause, because extra variables are cleared at every wake.

See also