Re: Inform lighting tricks?


06 Jun 1995 16:31:01 GMT

In article <60.5657.4154.0N1E56B6@canrem.com> tim.middleton@canrem.com (Tim Middleton) writes:

What is and 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 elaborite 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.

i don't know if there is an easier way than this, given your requirement
for several overlapping lamps. here's a sketch (in a hellish mixture of c
and inform, i'm afraid):

+ each room has a property 'light_val' which is initially 0
+ each lamp has a property 'lights_locs' with value a list of the rooms it
can illuminate
+ each lamp has a property 'light_flag' which is a distinct power of 2 (ie
lamp1 uses 1, lamp2 uses 2, lamp3 uses 4, etc)
+ when you switch on lamp:
for room in lamp.lights_locs
{
room.light_val |= lamp.lights_flag;
if (room.light_val != 0)
give room light;
}
(use the 'lamp.&lights_loc' and 'lamp.#lights_loc' constructions for the
iteration);
+ when you switch off lamp:
for room in lamp.lights_locs
{
room.light_val &= ~lamp.lights_flag;
if (room.light_val == 0)
give room ~light;
}

hope this is helpful; maybe someone else will think of a more ingeneous
solution.

-- richard

-- 
_______________________________________________________________________________

richard barnett richard@wg.icl.co.uk _______________________________________________________________________________