Re: Inform lighting tricks?


06 Jun 1995 20:49:53 GMT

Tim Middleton <tim.middleton@canrem.com> wrote:
> What is a good way in Inform to create a light source that illuminates
> several rooms at once? (ie. One switch controls lights for many
> rooms).
>
> I guess I could do some more elaborate programming of this lamp to
> literally grant "light" attribute to each room when it's turned on and
> take it away if it's turned off. This gets tricky because I want to
> have several lights and they overlap certain areas they illuminate. So
> if just one of the lamps is on then certain same areas will be
> lighted.

One way to do this is to have one object representing each light, and
use the "found_in" property to put each lamp in the various locations.
For example, here is a set of three rooms, each with a switch that
controls the lighting in the other two rooms:

Object RoomA "Room A" with description "Room A", e_to RoomB;
Object RoomB "Room B" with description "Room B", e_to RoomC, w_to RoomA;
Object RoomC "Room C" with description "Room C", w_to RoomB;

Class SwitchClass
has switchable static on
with name "light" "switch",
short_name "light switch",
after [;
SwitchOn: give self.number light;
SwitchOff: give self.number ~light;
];

Object SwitchA "x" RoomA class SwitchClass with number LightA;
Object SwitchB "x" RoomB class SwitchClass with number LightB;
Object SwitchC "x" RoomC class SwitchClass with number LightC;

Class LightClass
has light scenery
with name "fluorescent" "light",
short_name "fluorescent light";

Object LightA "x" class LightClass with found_in RoomB RoomC;
Object LightB "x" class LightClass with found_in RoomA RoomC;
Object LightC "x" class LightClass with found_in RoomA RoomB;

An alternative solution, which would be necessary if you had portable
lanterns that illuminated several nearby areas, would be to Replace the
OffersLight() library routine with a different algorithm for determining
whether an object is lit; the new algorithm would cast light from room
to room appropriately.

--
Gareth Rees