Extinguishing Lights

Post » Sat Oct 15, 2011 5:32 pm

Hello there modders,
a while ago, wrinklyninja posted a script in the All Natural thread that would allow a light to be turned off if activated. I recently discovered this post and was very excited by the idea of having an "Extinguish the Lights" type mod that could be easily made for All Natural-Real Lights, so I tried knocking up a quick global script that would add wrinklyninja's script to every non-scripted light reference in the player's current cell. I tested it out, and it worked for the most part. Unfortunately, it seems that if there are multiple lights with the same base object, only one of the lights can be turned off/on. The other references with that base object remain unaffected. I guess this has to do with the script being added to the base object, rather than being added to each unique reference, but both my modding and my programming knowledge are rather limited, so I have no idea how I would fix this problem. Help would be greatly appreciated. Here are the two relevant scripts, the first one being wrinklyninja's light extinguisher, the second one being my global script.

scn aaPapAddScriptsScriptfloat fQuestDelayTimeref lightRefref LightScriptshort iniBegin GameMode        if ini == 0                set ini to 1                set LightScript to aaPapLightTest        endif        let fQuestDelayTime := 1        set lightRef to GetFirstRef 26        Label 10        if ( lightRef ) ; continue until all refs are processed                if lightRef.IsScripted == 0                        lightRef.SetScript LightScript                endif                set lightRef to GetNextRef        Goto 10        endifend

scn aaPapLightTestarray_var rgbarray_var rgbbaseshort flamesshort waitBegin OnActivatelet rgb := GetLightRGBif Eval (rgb[0] + rgb[1] + rgb[2] > 0)        let rgbbase := rgb        SetLightRGB ar_List 0 0 0        set flames to 1elseif Eval (rgb[0] + rgb[1] + rgb[2] == 0)        SetLightRGB rgbbase        set flames to 2endifUpdate3Dprintc "LightTggle"EndBegin GameModeif wait        if CanHaveFlames                if flames == 1                        RemoveFlames                else                        AddFlames                endif        endif        set wait to 0        set flames to 0endifif flames        set wait to 1endifEnd


Cheers,

Papierhut
User avatar
YO MAma
 
Posts: 3321
Joined: Thu Dec 21, 2006 8:24 am

Post » Sat Oct 15, 2011 11:51 am

Just a couple of points to start with.

The first script will re-evaluate whether the lights are scripted or not a lot of times if you do it every frame, AND reduce the script delay. You only need it done once when the player's cell changes. Use a GetInSameSell test and drag around a marker rat or something to avoid the repeats. This may be the cause, if the logic is getting restarted too much it may never get past the first one.

You're using OBSE in the second script (presumably the copied code) so use it for the loop in the first one instead of the Goto! While or ForEach as applicable.
User avatar
GLOW...
 
Posts: 3472
Joined: Thu Aug 03, 2006 10:40 am


Return to IV - Oblivion