MajorKirrahe89 Posted November 15, 2022 Share Posted November 15, 2022 (edited) 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 November 15, 2022 by MajorKirrahe89 Link to comment Share on other sites More sharing options...
RomanR Posted November 16, 2022 Share Posted November 16, 2022 (edited) 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 November 16, 2022 by RomanR Link to comment Share on other sites More sharing options...
MajorKirrahe89 Posted November 16, 2022 Author Share Posted November 16, 2022 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 More sharing options...
RomanR Posted November 16, 2022 Share Posted November 16, 2022 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 More sharing options...
MajorKirrahe89 Posted November 16, 2022 Author Share Posted November 16, 2022 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 More sharing options...
GamerRick Posted November 16, 2022 Share Posted November 16, 2022 You can't move, rotate, or scale most object types without doing the disable/enable thing on them, and it always makes them flicker. So, it isn't just lights that have that problem. Link to comment Share on other sites More sharing options...
RomanR Posted November 16, 2022 Share Posted November 16, 2022 And what's the problem to not use additional object? Again with right timing you can achieve almost real-time results. Link to comment Share on other sites More sharing options...
GamerRick Posted November 17, 2022 Share Posted November 17, 2022 So, you would have another object that gets enabled while the main one is disabled? Interesting.... Link to comment Share on other sites More sharing options...
RomanR Posted November 17, 2022 Share Posted November 17, 2022 @GamerRick:Yes, this si a principle of double-buffering, just for this case applied to objects. Link to comment Share on other sites More sharing options...
MajorKirrahe89 Posted November 17, 2022 Author Share Posted November 17, 2022 But if I'd like to have smooth, gradual light transition from day to night and vice versa, it would require many light objects. Given that house has about 25 windows = 25 light objects for just 1 light state... Too messy for my tastes. Link to comment Share on other sites More sharing options...
Recommended Posts