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