Manual:DIL Manual/mudhour

From DikuMUD Wiki
Jump to navigation Jump to search

mudhour

Variable (integer, read-only).

mudhour : integer

The hour of the mud day, 0 to 23: 0 is midnight, 12 noon. A mud hour lasts 5 real minutes.

Notes

  • Day and night (weather.cpp): the sun rises at hour 5, it is day from 6 to 20, the sun sets at 21, and from 22 to 4 it is night. spells.zon's sun spells refuse to work when (mudhour < 5) or (mudhour >= 21).
  • 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: mudhour() doesn't compile. It can't be assigned.
  • An NPC that waits for an hour should wait with a heartbeat shorter than a mud hour and check mudhour at each tick, as midgaard.zon does with heartbeat := WAIT_SEC*SECS_PER_MUD_HOUR/2; and while ((mudhour != 6) and (mudhour != 18)) pause;.

Example

dilbegin integer in_hours(from : integer, until : integer);
code
{
   if (from < until)
      return ((mudhour >= from) and (mudhour < until));
   return ((mudhour >= from) or (mudhour < until));
}
dilend

Tells whether the hour is in [from, until); hours wrap round, so in_hours(20, 6) is the night. It is quests.zon's inHours.

See also