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

Day/Night Dynamic Lighting Script?

I'm wondering if there is a wat to script a token to control the dynamic lighting brightness?  I am currently using a multisided token to show the time of day for players, but thought it would be handy to have it control the dynamic lighting brightness too.  As opposed to clicking on the map and editing it settings manually. Is that possible?
If you're looking to toggle 'Global Illumination' off and on, you can use  this scriptlet .
1652826657

Edited 1652873527
David M.
Pro
API Scripter
Here's a quick script that affects the Player ribbon page. Just threw this together with no error handling to speak of and barely tested, lol, so let me know if you run into issues. Syntax !daylight <#>        //where # is between 0 and 1 Code: const Daylight = (() => { const version = '0.1'; const scriptName = 'Daylight'; const checkInstall = () => { log(`-=> ${scriptName} v${version}<=-`); }; const handleInput = (msg) => { if (msg.type === "api" && msg.content.toLowerCase().indexOf("!daylight") === 0 ) { let args = msg.content.split(/\s+/); if (args.length > 1){ let opacity = parseFloat(args[1]) || 0; let page = getObj('page', Campaign().get('playerpageid')); if (page) { page.set({daylightModeOpacity: opacity, force_lighting_refresh: true}); } } } }; const registerEventHandlers = () => { on('chat:message', handleInput); }; on('ready', () => { checkInstall(); registerEventHandlers(); }); })(); Example macro: !daylight ?{What light level?|Pitch Black,0|Dim Moon,0.2|Bright Moon,0.35|Dawn/Dusk,0.55|Moderately Bright,0.7|Very Bright,1.0}
1652834229
Oosh
Sheet Author
API Scripter
The handleInput conditional looks a little iffy, David.... :)
That's perfect David, thanx
1652873447
David M.
Pro
API Scripter
Oosh said: The handleInput conditional looks a little iffy, David.... :) Ah, yes, thx. Though, you could probably say that about most of the code that I write :)  I usually put everything into a (true && true) block so I don't have to think very hard lol. Not sure why I went off book. I'll update above.
If you are using legacy dynamic lighting Torch api has a global on/off and DL on/off switch.  I would not worry too much about stuff like this in a session, they are playing a tabletop game not a video game.  The effort in this would be better served describing the game more to them than fiddling with the tools you use to display the tabletop to them.  
1652963460
David M.
Pro
API Scripter
There are many different playstyles. I've played in IRL groups that used nearly 100% Theater of the Mind and those that used hyper-realistic terrain and miniatures, too. If the GM wants to spend time/effort on the little things for the sake of immersion or even just because they enjoy it or think it's cool, more power to them! I've tried out a bunch of things in my Roll20 games - some added a lot of value to me and my group and many things I let fall off the radar because of cost/benefit. Eventually games will settle into a state that is both manageable and fun. This will be different at every table, virtual or otherwise.