Manual:DIL Manual/islight()

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

islight()

Function (integer). Tells whether there is light in a room.

islight(u : unitptr)

Returns TRUE when u is lit and FALSE when it is dark. Give it a room, usually self.outside: that is how the look and exits commands decide whether to say It is pitch black. It does not tell whether an object gives light; that is the bright field.

Parameters

Name Type Meaning
u unitptr The room (or other unit) to test.

Returns

Integer: TRUE or FALSE. It fails when u is null.

Notes

  • The light is u.light (the unit's own light plus what the light sources in it
 give), plus the light of the unit it is in, plus daylight unless u
 has UNIT_FL_INDOORS: +1 by day, 0 at sunrise and sunset, -1 at night. It is lit
 when the sum is 0 or more.
  • So a room with no light setting is always lit indoors and dark outdoors at night. The macros
 in wmacros.h set it: ALWAYS_LIGHT (light 1),
 IN_ALWAYS_DARK and OUT_DARK_NON_NOON (light -1),
 OUT_ALWAYS_DARK (light -2); a torch carried in adds its light.
  • On a character it adds the character's own light, the room's and daylight even indoors
 (a character has no UNIT_FL_INDOORS), which says nothing useful: pass the room.

Example

dilbegin do_peer(arg : string);
code
{
   if (not islight(self.outside))
   {
      act("It is pitch black.", A_ALWAYS, self, null, null, TO_CHAR);
      quit;
   }

   act("You peer around $2n.", A_ALWAYS, self, self.outside, null, TO_CHAR);
   quit;
}
dilend

A player command that does nothing in the dark, as direc_dil in basemove.zon (the exits command) starts.

See also