Page 1 of 1

Creating a light switch

Posted: Fri Oct 19, 2012 5:39 am
by Periodiko
I've been having some problems with dynamic light sources, and I was wondering if someone could help.

I'm trying to implement some dynamic light sources that can be turned off and on by scripts. The important part is that the light status must persist between saving and loading. Generating an fx object via a spawn script or direct placement then destroying the fx object when the light is off doesn't work, because fx objects do not record to saved data. Further, creating Lightsource objects like the temple_ceiling_lamp objects, and tweaking them via fx functions doesn't seem to work either - it crashes the script editor/game.

I feel like I have to be missing an obvious solution.

Oh, one other question: I created some custom light source objects, and one thing I noticed was they flicker slightly. Is there some setting that controls whether lights flicker? Brightness perhaps?

Re: Creating a light switch

Posted: Fri Oct 19, 2012 5:54 am
by Batty
You should be able to use spawn(object, level, x, y, facing, ID) and destroy() with your LightSource objects to add/remove on the fly and persist through saves. As for the flickering, I know that's been discussed elsewhere so do a flicker search. 8-)

Re: Creating a light switch

Posted: Fri Oct 19, 2012 6:09 am
by Periodiko
Well, regardless, I just discovered that Lightsource objects have a different set of functions from fx objects, including a very simple Activate() Deactivate(), so I feel like a dummy. I'm not sure what you describe specifically would work with fx objects, though - I'm pretty sure spawned fx objects do not get saved, which was how I was doing some of the lights.