Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Updated Dynamic Lighting - Flashing Lightning Effect?

Hi all, Spent a while searching for this without much luck (the small number of relevant posts seem to be very old and don't seem to work with the updated dynamic lighting). I'm looking to create a lightning style lighting effect on one of my pages. My javascript capability is very limited... but I guess there's multiple ways this could be achieved. The main two I can think of being; A token that has its 'Bright Light' value changed between 0 to 1000 for a short period of time, and this loops/happens at random intervals. I know TokenMod can change this value, but I believe having this happen repeatedly would need to be done via the API?   The who page is switched to daylight mode for a short period of time, and this then loops as above. I can see there's a 'daylight_mode_enabled' command within the API to do this, but as I said - my js isn't anywhere close to being good enough to do the timing. Is this something that's been done before? I've looked at this  Flickering Lights  scripts, but can't get it working. I contemplated using !delay to create a simple macro to do this, before deciding that was probably not the best way to do this. Any help or suggestions would be greatly appreciated!
1605999238

Edited 1606044799
David M.
Pro
API Scripter
I wrote a little lightning script a few months ago. It uses LDL, but you could easily modify it for UDL (change to UDL token properties in the "flashOn" and "flashOff" functions). Forum thread with github link and documentation can be found here . EDIT - oops not a github link, it was short enough that I put the whole script in the main forum post.
1606039833

Edited 1606039916
Awesome. Thanks, David. I'll take a look! The biggest difficulty when searching was trawling through all the posts where people had incorrectly typed 'light n ing' when they were actually just talking about normal lighting...
To update, I think I've got this working. It was mostly straightforward, but it seems a 0 value in UDL when "emits_bright_light" or "emits_low_light" are set to true results in a 5 ft light around the token. To fix this I just toggled those values too. Previous; const flashOff = function(src) { src.set('light_radius', 0); } const flashOn = function(src, dim, timeout) { let rand = Math.random() * timeout; if (dim) { src.set('light_dimradius', -15); src.set('light_radius', 200); } else { src.set('light_radius', 200); } setTimeout(flashOff, rand, src); } Tweaked for UDL; const flashOff = function(src) { src.set('bright_light_distance', 0); src.set('low_light_distance', 0); src.set('emits_bright_light', false); src.set('emits_low_light', false); } const flashOn = function(src, dim, timeout) { let rand = Math.random() * timeout; if (dim) { src.set('emits_bright_light', false); src.set('emits_low_light', true); src.set('low_light_distance', 500); src.set('bright_light_distance', 0); } else { src.set('emits_bright_light', true); src.set('emits_low_light', false); src.set('bright_light_distance', 500); } setTimeout(flashOff, rand, src); }
1606086351
David M.
Pro
API Scripter
Great, glad you got the conversion working! Happy gaming!