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

[Suggestion] Automated Torch

I'm very new to Java, but from what I've seen reading through the documentation, it seems like it would be possible to say... Have a multi-sided token with sides for lit/unlit torch, make this token non-drawing, give it a specific name, and set it as a default token for the character Torch, for ease of creating copies... and then a script that checks for tokens with that specific name, and puts it on the unlit torch side when a certain variable is 0, but will switch it to the lit torch side and set a light radius equal to that variable if it's greater than 0?
Part of the script I wrote for tracking consumption of torches over time (and diminishing light radius as they approach burning out) automates turning the light radius for torches on and off, although I've implemented it differently than how you describe it. It hadn't occurred to me to try a multi-sided token for lit/unlit -- I haven't done much with rollable tables yet.&nbsp;Here's the link: <a href="https://app.roll20.net/forum/post/158922/script-time-slash-torch-tracker#post-165752" rel="nofollow">https://app.roll20.net/forum/post/158922/script-time-slash-torch-tracker#post-165752</a> The on/off function uses any generic token named "Torch," which it expects to have a current/max value for Bar 1 (representing remaining/total burning time), and uses Bar2 to turn the light on or off -- 0 is off, 1 is on (and the script converts any positive number to 1 and any negative number to 0, for a "clean" display).&nbsp; If you don't care about the time tracking functions and just want the on/off switch, you can chop out this whole block: on("chat:message", function(msg) { ... }; and if you don't care about the light radius diminishing as the torch burns lower, you can simplify the if ... else block in the updateLights function to only check on/off status, and get rid of the references to burningTimeTotal and burningTimeRemaining.&nbsp; I'm not going to attempt to add multi-sided tokens for my script (yet -- although I like the idea a lot), mostly because one of the 0-level scrubs in my upcoming DCC game lucked out and got a lantern as their random starting gear. So now I have to extend the script to cover lanterns. ;-) But if you're learning javascript (or any programming language), the two best things I can recommend are a project you really want to realize -- no better motivation than making your own cool idea a reality -- and finding some code that does something similar to what you want to do, and shamelessly ripping it off &nbsp;learning from it. So have at it!
Awesome, thanks for the tips and link, nice script!
You're welcome! Glad you liked it.&nbsp;