Manual:DIL Manual/mudday

From DikuMUD Wiki
Jump to navigation Jump to search

mudday

Variable (integer, read-only).

mudday : integer

The day of the mud month, 0 to 13. A mud day lasts 2 real hours; mudday changes at midnight (mudhour 0).

Notes

  • The time command (commands.zon) shows mudday + 1 as the day of the month, and takes the day of the week from mudday % 7.
  • For "once a day", keep the last day seen and compare, as the shops in function.zon do to restock (if (mudday != prev_mudday)).
  • The calendar (vme.h): an hour is 5 real minutes (SECS_PER_MUD_HOUR), a day 24 hours (2 real hours), a month 14 days (MUD_MONTH; the comment beside it in vme.h still says 21), a year 9 months (MUD_YEAR, 10.5 real days). The count starts on 11 August 1990.
  • The mud clock is the real clock at boot plus the game ticks since (mud_date in weather.cpp). Normally it keeps pace with real time; with vme -w, or after a god's wtimewarp, it runs ahead, so code that waits for a time of day can be tried quickly.
  • Written without brackets: mudday() doesn't compile. It can't be assigned.

Example

dilbegin daily_stock(sym : string);
var
   lastday : integer;
   u       : unitptr;
code
{
   heartbeat := PULSE_SEC * 60;
   lastday := mudday;

   :start:
   wait(SFB_TICK, TRUE);
   if (mudday == lastday)
      goto start;
   lastday := mudday;
   u := findsymbolic(self, sym, FIND_UNIT_INVEN);
   if (u == null)
   {
      u := load(sym);
      exec("emote unpacks a fresh crate.", self);
   }
   goto start;
}
dilend

A shopkeeper (dilcopy daily_stock@zone("bread@zone");) that once a mud day loads a new item of a kind when it has none left.

See also