Jump to content

SetLightRGB OBSE function problem


Recommended Posts

Hello, I'd like to change light RGB values with a script, but I have encountered some problems. There's no light emission at all in-game, but when I hit ~ and open console, the light is just like it should... as long as the console is opened. My script looks like this:

begin GameMode

        if (GameHour > 5 && GameHour < 8)
            let windlight := ar_construct array
            
            let windlight[0] := 0 + 50 * (GameHour - 5)
            let windlight[1] := 0 + 50 * (GameHour - 5)
            let windlight[2] := 0 + 50 * (GameHour - 5)
            
        SetLightRGB windlight MjrKDaylight512PARENT
        MjrKDaylightPARREF.Update3d
        elseif (GameHour > 18 && GameHour < 21)
            let windlight := ar_construct array
            
            let windlight[0] := 150 - 50 * (GameHour - 18)
            let windlight[1] := 150 - 50 * (GameHour - 18)
            let windlight[2] := 150 - 50 * (GameHour - 18)
            
        SetLightRGB windlight MjrKDaylight512PARENT
        MjrKDaylightPARREF.Update3d
        elseif (GameHour >= 8 && GameHour <= 18)
            let windlight := ar_construct array
            
            let windlight[0] := 150
            let windlight[1] := 150
            let windlight[2] := 150
                    
        SetLightRGB windlight MjrKDaylight512PARENT
        MjrKDaylightPARREF.Update3d
        else
            let windlight := ar_construct array
            
            let windlight[0] := 0
            let windlight[1] := 0
            let windlight[2] := 0
            
        SetLightRGB windlight MjrKDaylight512PARENT
        MjrKDaylightPARREF.Update3d
        endif
    
end

When I change GameMode to OnActivate, light is udpated with a proper value everytime I'll activate the object. But it's useless to me that way. Does Update3d or SetLightRGB functions don't work on GameMode basis?

 

EDITED

 

OK, I just realized it's probably problem with light object being updated constantly, hence the "no light emission" (object "flickers" when updated, like it's been disabled/enabled very quickly, so being updated all the time, it's "invisible"). That raises another question: is there a way to make light from light object gradually and smoothly darken/lighten, with no visible flickers and such?

Edited by MajorKirrahe89
Link to comment
Share on other sites

The easiest way would be to make simple frame counter:

set framecount to framecount + 1
if framecount == 2 ;every second frame
   set framecount to 0
endif
if framecount == 0
   .........
   {your commands}
   .........
endif

A little more difficult would be to implement flags representing color of light through a day and also flag which would indicate that a color of light is set.

Also why I see so much commands to construct same field? You can use ar_Size function on the start of the script and if it returns -1, only then you need to construct it.

let size := ar_Size windlight
if size == -1 
   let windlight := ar_Construct array
endif
Edited by RomanR
Link to comment
Share on other sites

I have used GetSecondsPassed function with timer variable to make it fire every five seconds, and it works as intended with one "slight" problem - light object is disabled/enabled for a split-second when updated and it's clearly visible, 'cause for that moment light is off. So I have to find another solution to achieve the same goal or abandon the idea.

 

 

Also why I see so much commands to construct same field?

 

Yeah, I know it can be done better, but it was just a quick try. The final script, if it'd work, would be cleaner.

Link to comment
Share on other sites

I faced similar problem while I was working on Magic Torch mod as a result of thread started by bomo99. In this mod I was quite successful using the second light to mask this blinking. However the timing must be very precise and still some sort of small blinking can be seen (personaly I didn't notice, but it's reported in comments). But since you will use the change of light color only 4 times for a day, I think that nobody will care much.

Link to comment
Share on other sites

But since you will use the change of light color only 4 times for a day, I think that nobody will care much.

I would like to achieve the effect of sunrise/sunset, so the light would gradually lighten/darken in the morning and evening. If it was just "static" change of light color I'd probably just go with additional light objects and enable/disable them when needed and wouldn't bother with that Update3d blink.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...