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

Off/On switch for dynamic lighting, line of sight.

I've been messing with the Light Switch script. Is there a simple way to turn on and off Dynamic Lighting and Line of Sight with an API script? I did not see one. We've been doing a lot of day/night adventures and though it shaves off just 10~20 seconds it would be useful for me at least.
1408458978
The Aaron
Roll20 Production Team
API Scripter
Which Light Switch script, can you post a link? Which settings are you trying to turn off and on?
Hello Aaron, it is under the API listing: Light SwitchScript for turning on and off lights with chat commands. It allows you to turn lights off and on from the chat window. I have barely delved into it but I figure if you can change the lighting like that, why not change the map global dynamic lighting and line of sight the same way? I looked for a script but did not find one. When you edit a sheet/map you have the option to enable dynamic lighting and line of sight. Instead of having to go up to the settings for the sheet/map I want to control it via the api. Found myself having to go change it four or five times last nine hour session. Thanks.
1408460224
The Aaron
Roll20 Production Team
API Scripter
The settings are exposed to the API via the Page object: <a href="https://wiki.roll20.net/API:Objects#Page" rel="nofollow">https://wiki.roll20.net/API:Objects#Page</a> This is very doable. What commands do you see yourself executing for this, and what is there effect? Example: !day might turn off line of site, turn off dynamic lighting, !night might turn on line of sight and turn on dynamic lighting.
Your example is exactly what I am looking for at this time. And, to my embarrassment, I missed the API Objects Page some how....
1408460808
The Aaron
Roll20 Production Team
API Scripter
Easy to miss. =D So, will that let you write a script for it, or do you need assistance?
Some assistance would be great; I sit in front of a computer 14 hours a day for my job right now. Would love to sharpen my atrophied javascript skills but it won't happen anytime soon.
1408461733
The Aaron
Roll20 Production Team
API Scripter
=D I highly recommend Javascript: The Good Parts by David Crockford. It's certainly helped me with my Javascript chops. =D Fast easy read and very well written.
I'll look it up, thanks.
1408462970
The Aaron
Roll20 Production Team
API Scripter
<a href="https://app.roll20.net/forum/post/1104897/script-t" rel="nofollow">https://app.roll20.net/forum/post/1104897/script-t</a>... ;)
Hmm, not working but not getting an error message on the API console either. Says it is spinning up a new sandbox. Perhaps I am not giving it enough time to load?
1408463879
The Aaron
Roll20 Production Team
API Scripter
Did you install the isGM script? Also, did you speak once in the chat as yourself to let the isGM script detect you as a GM?
I installed the isGM script; but had failed to allow it to detect me... Got it to work: once. I was on a page, toggled day/night. Swapped pages, and no go. Will continue testing as time permits.
1408464415
The Aaron
Roll20 Production Team
API Scripter
When you swapped pages, did you move the player ribbon? It triggers off of the player page (there's no way to detect what page the GM is on).
1408464457
The Aaron
Roll20 Production Team
API Scripter
I considered adding an option to select a token and use it's page, then fall back on the player page.
Ah, gotcha. I did not move the ribbon page. But your torch and snuff works fine without moving the ribbon. Thank you for writing this for me; it will certainly speed things up.
1408465037
The Aaron
Roll20 Production Team
API Scripter
Ok. I updated the script to take the page from the selected token, so you can turn it off and on on pages where the players aren't, or where only one player is. I also added a whisper to chat that tells you what it did and the name of the page. Cheers!
And since the torch and snuff work on that particular object of course it doesn't care what page you're on as GM from what I can surmise.
1408465327
The Aaron
Roll20 Production Team
API Scripter
Correct. Also, players can use those.
Had a pretty complicated battle between the human party and goblins who focused on trying to get rid of lights if they could. Had to go in and edit lots of tokens during the fight. This will sure speed things up.
1408465486
The Aaron
Roll20 Production Team
API Scripter
yup. Works with multi-select, so you can turn off/on a whole bunch at once. =D
Quiet unique your code. don't often see ppl script Object Oriented in JS. but it'S nice i'll steel that Thx ;)
1408481841
The Aaron
Roll20 Production Team
API Scripter
=D Closures are the best feature of Javascript, as far as I'm concerned. David Crockford talks a bunch about them in his book Javascript: The Good Parts , which I highly recommend for anyone writing Javascript. If you look in my Gists, you can certainly tell at what point I read it. =D
Aaron, do you know of a status marker changing script? Something that will take an argument and turn on the skull or whatever desired marker on a token? (Just abusing you today aren't I?)
1408492072
The Aaron
Roll20 Production Team
API Scripter
Hmm. I have one that turns it on based on one of the bars. It wouldn't be hard to make one.
I'm going to have to order that book; local bookstores don't stock it I found out.