Scripts / Fade to Black

Author
Message
SirDrake
Reviewed GameGuru on Steam
6
Years of Service
User Offline
Joined: 8th May 2017
Location: Nova Scotia, Canada
Posted: 2nd Nov 2017 00:31
I've been trying to create a script to dim the lights or gradually "fade to black" when player enters zone. I found that SetBrightness(v) seemed to be the place to start. Figured to use a variable that would incrementally change brightness. First tried a "for i = 1, 10 do block end" type of command - didn't work. Then I went with a "while i <10 do block i=i+1 end" method - again didn't work. What seems to happen is that everything freezes til the "while" has finished then it does the block of commands. It might be that the calculation runs faster than the brightness can be changed. I've attached my lua, can anyone help!

Attachments

Login to view attachments
PM
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 2nd Nov 2017 15:18
Hi,

I would use a block as below, with a basic "if then" structure, with a timer delay to control the steps.
So in the init(e) you would give delay a value so you can compare it to the timer value.
ie: delay = 100



Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, ~3.6GHz, Windows 10, 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768.
Operating System: Windows 10 Home 64-bit (10.0, Build 15063) (15063.rs2_release.170317-1834)
PT V9.0 3DMark=4344, Passmark=3291.

Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
PT V9.0 3DMark=377, Passmark=1222.
SirDrake
Reviewed GameGuru on Steam
6
Years of Service
User Offline
Joined: 8th May 2017
Location: Nova Scotia, Canada
Posted: 2nd Nov 2017 23:27 Edited at: 2nd Nov 2017 23:28
Thanks loads. The "delay" idea worked. Had to make one change, the "StartTimer(e)" command kept resetting timer. I moved it and added a variable condition.
PM
SirDrake
Reviewed GameGuru on Steam
6
Years of Service
User Offline
Joined: 8th May 2017
Location: Nova Scotia, Canada
Posted: 3rd Nov 2017 00:18 Edited at: 3rd Nov 2017 00:37
Boy I had it wrong. After looking at the new code for awhile I realized I had basically destroyed the delay function, but it still worked, didn't need a delay. I finally figured it out. It was just so simple - get rid of "and drk == 0" in line 10, also changing to "for next" instead of "while do". Thanks again, your snippet is what solved it!
PM
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 4th Nov 2017 20:28
Thanks
I am glad you got it working as you wanted.
Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, ~3.6GHz, Windows 10, 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768.
Operating System: Windows 10 Home 64-bit (10.0, Build 15063) (15063.rs2_release.170317-1834)
PT V9.0 3DMark=4344, Passmark=3291.

Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
PT V9.0 3DMark=377, Passmark=1222.

Login to post a reply

Server time is: 2024-03-29 06:35:17
Your offset time is: 2024-03-29 06:35:17