Re: Inform lighting tricks?


Tue, 06 Jun 1995 13:43:19 -0700

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

> 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).

---snip---

> 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.

Tim,
My solution would be as follows;

Create an attribute for each light switch:

Attribute switch1;
Attribute switch2;

The code for each switch would be:

Nearby Switch_One "lightswitch"
with name "lightswitch",
description "Use this to turn the lights on and off.",
after [;
SwitchOn: give Room1 switch1; give Room2 switch1;
SwitchOff: give Room1 ~switch1; give Room2 ~switch1;
],
has switchable, static

In the SwitchOn and SwitchOff section you list every room that this switch
gives light to. Then the code for each lightable room should include:

each_turn [;
if (self has switch1 || self has switch2) give self light;
give self ~light;
],

The if statement should include each switch that is capable of giving the
room light. This will enable the room to remain lit even if switch1 is
turned off -- as long as switch2 on. Be sure you don't give the room the
'has light' attribute.

I hope this helps you,
Ron