Manual:DIL Manual/islight()
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 thelightof the unit it is in, plus daylight unlessuhasUNIT_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
inwmacros.hset it:ALWAYS_LIGHT(light 1),IN_ALWAYS_DARKandOUT_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.