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

[Script] Torch -- A simple script for giving lights to tokens and turning off and on dynamic lighting.

August 19 (10 years ago)

Edited March 23 (8 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update 0.8.10 -- Changed Flickers to respect the rotation of their parent. (Thanks Samuel T.)
Update 0.8.5 -- Moved Flickers to the Dynamic Lighting layer so they don't interfere with selections.  (Thanks vorgrist!)
Update v.7 -- Added Flicker Light support, ala Jack Taylor's marvelously clever Flickering Lights Script. Thanks Jack!
New Commands:
  • !flicker-on -- Just like !torch, with all the same options. Creates a flickering light that stays with the token. This effectively allows players to carry a flickering torch, as movement is not restricted. This also allows lights set by !torch, if for example you want your players to carry a torch but also have darkvision.
  • !flicker-off -- Just like !snuff, with all the same options. Removes a flickering light from the selected and/or supplied tokens.
Flickering Lights only flicker on pages the players are on (GMs can drag themselves to the page to work on a map without fear of players being there.) and are persisted across script restarts.

Update v.61 -- Removed direct use of HTML entities to prevent the substitution bug.
Update v.6 -- Several updates in this version:
  • Added supplying of Token IDs on the command line via @{target|token_id}. You can specify as many as you like, and duplicates are ignored (incase you want to have a macro that takes a bunch and then just click them all off on a couple people).
  • Fixed parsing of !torch arguments that are not numbers, now they will default to the default values instead of crashing the script.
  • Added '-' as an 'on' parameter for Players see Light. This means you can supply '-' as a default for all arguments to !torch if you just want to supply Token IDs
  • Added a help screen. You can access it by supplying 'help' as the first argument to any of the commands, as well as by calling !torch or !snuff with nothing selected and no Token IDs as arguments.

Update v.5 -- Fixed bug in v.4 which caused the 3rd parameter to not be used, and the default to be players can't see the light. (Thanks Leo!)
Update v.4 -- Added a 3rd parameter to !torch to allow setting whether other players see light.
Update v.3 -- Added feedback about which page is being changed for !daytime and !nighttime, added taking the pageid form a selected token by default, and falling back to the player's current page.

This is a script I wrote a while ago, but never made a post specifically for. I've updated it with some recent related feature requests.

!torch [bright radius] [dim radius] [other players] [token id ...]-- For the selected/supplied tokens, it causes them to emit light. By default, the light is 40 bright, dim for half, but you can specify one or both. Sets other players see light to true by default, false if other players is not one of 1, on, yes, true, sure, yup, -.
!snuff [token id ...] -- Removes the light from selected/supplied tokens.
!daytime [token id] -- (GM Only) Turns off the dynamic lighting for the player's page (note that as a GM, you may not be on that page). Selecting a token or supplying a token ID will cause it to adjust the lighting for the page of the selected/supplied token.
!nighttime [token id] -- (GM Only) Turns on the dynamic lighting for the player's page (note that as a GM, you may not be on that page).Selecting a token or supplying a token ID will cause it to adjust the lighting for the page of the selected/supplied token.

Sorry.. no pretty help page for this yet.

Git: https://github.com/shdwjk/Roll20API/blob/master/To...
If you use my scripts, want to contribute, and have the spare bucks to do so, go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free!
Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
you know you can have this include a timer for light sources, then have it tick down as people move around a darkened house or a deep dungeon underground. or even at night in a dark forest. been done before poorly, but if you have it detect if the initiative page is up and count down by rounds there, or by minute out of combat based on squares moved or by DM control (ie players rest for ten minutes, DM clicks on torch and reduces the time by 10 either by using a bubble or a command that reduces the time by an apropriate amount of time (ten minutes in this case).

The timekeeping part of the script can be added to a function utility base that will allow anyone to hook into it, letting them do the same thing with other time related things (tracking spells, buffs, debuffs, and battery life or power levels, if someone wanted to keep track of that for a modern or futuristic game - even fuel) because we all know you will most likely write the most user-friendly version of such a function, and document it perfectly for those who know how programming works. cleanest code i have even seen on this site comes from you, even if i can only follow half of it.

I dunno, you're always busy, but I believe this would be a great little addition to any campaign, Hoping I see what I suggest coming through.

August 20 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Thanks for the kind words!

Yeah, I certainly have lots of irons in the fire right now. Those are some fun ideas, I'll think about them. I have a modification to work on for adding hours/minutes tracking to my calendar script (along with many other things), which could be tied into for such things at some point.
August 20 (10 years ago)
This is a nice, simple script that actually will speed up a lot of things related to lighting. Being able to make a macro button to quickly apply and remove light from tokens is nice.

However, one quick suggestion: I made a button for Dark/Low-Light vision, and the only thing that's missing is an input command to toggle on/off the All Players See Light option, because that seems to go on by default. If that could be an input option, or I missed the part where it is and it's already there, it would be pretty much perfect.
August 20 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update v.4 -- Added a 3rd parameter to !torch to allow setting whether other players see light.

=D You can specify one of 1, on, yes, true, sure or yup as the 3rd parameter to turn on show players explicitly, or any other value to turn it off. It still defaults to on.

So, for dark vision 60', you could use:
!torch 60 60 off
August 20 (10 years ago)
Dig, I appreciate it man.
August 20 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Yup, no problem!
August 22 (10 years ago)
Hello,

I am testing this script which seems very useful but right now I cannot get the third argument to work. I am not sure what information you need to reproduce the problem (I'm new to roll20, the API and js).

Anyhow, I am using IsGMModule.js, TokenLock.js (with suggested line modification between lines 99 and 100), TurnMaker.js and finally Torch.js They were all created/maintained by @Aaron.

Currently, the first and second argument of the !torch command work, but for some reason the light is not visible to all players by default and the !torch command is unresponsive to this third argument.

Any help will be greatly appreciated
August 22 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Hmm. If you want to PM me an invite, I can join your campaign. Then you can GM me and I'll check what the issue is.
August 22 (10 years ago)
Ok, thank you!
August 23 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update v.5 -- Fixed bug in v.4 which caused the 3rd parameter to not be used, and the default to be players can't see the light. (Thanks Leo!)
September 06 (10 years ago)
Cool script very helpful!

Is it possible to get this where you can target someone with the change via @target?

The use case is simply because one challenge that I have is the macro bar is filling up, so I was thinking of linking these to a torch icon, that way when I needed them I could just drag out the torch icon and load it up with !torch targeted token actions, so that I can quickly and easily setup vision.
September 07 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
@Kevin -- Yeah.. it's possible... and now it's done!

Update v.6 -- Several updates in this version:
  • Added supplying of Token IDs on the command line via @{target|token_id}. You can specify as many as you like, and duplicates are ignored (incase you want to have a macro that takes a bunch and then just click them all off on a couple people).
  • Fixed parsing of !torch arguments that are not numbers, now they will default to the default values instead of crashing the script.
  • Added '-' as an 'on' parameter for Players see Light. This means you can supply '-' as a default for all arguments to !torch if you just want to supply Token IDs
  • Added a help screen. You can access it by supplying 'help' as the first argument to any of the commands, as well as by calling !torch or !snuff with nothing selected and no Token IDs as arguments.
November 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update v.61 -- Removed direct use of HTML entities to prevent the substitution bug.
November 11 (10 years ago)
vÍnce
Pro
Sheet Author
Hi Aaron. Any plans on updating the Torch script to include the new multiplier feature?
November 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Definitely! Unfortunately, we have to wait for the API's access to the data model to be updated. We don't currently have access to the field. I'm hoping we'll get access to this and the ambient light setting (and I hope the ability to set the gamma on it as well!).
November 11 (10 years ago)
vÍnce
Pro
Sheet Author
and I hope the ability to set the gamma on it as well

That would be nice. I currently use a token's aura with a huge radius to help "set the mood" on a map.
November 28 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update v.7 -- Added Flicker Light support, ala Jack Taylor's marvelously clever Flickering Lights Script. Thanks Jack!
New Commands:
  • !flicker-on -- Just like !torch, with all the same options. Creates a flickering light that stays with the token. This effectively allows players to carry a flickering torch, as movement is not restricted. This also allows lights set by !torch, if for example you want your players to carry a torch but also have darkvision.
  • !flicker-off -- Just like !snuff, with all the same options. Removes a flickering light from the selected and/or supplied tokens.
Flickering Lights only flicker on pages the players are on (GMs can drag themselves to the page to work on a map without fear of players being there.) and are persisted across script restarts.
November 28 (10 years ago)

Edited November 28 (10 years ago)
vÍnce
Pro
Sheet Author
Cheers Aaron. Thank you.
November 28 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
No problem! :)
December 31 (10 years ago)
vÍnce
Pro
Sheet Author

The Aaron said:

Definitely! Unfortunately, we have to wait for the API's access to the data model to be updated. We don't currently have access to the field. I'm hoping we'll get access to this and the ambient light setting (and I hope the ability to set the gamma on it as well!).
Any hints by the Devs that this might be in the works Aaron? Fingers-crossed.

December 31 (10 years ago)
The Aaron
Pro
API Scripter
I can neither confirm nor deny...

literally. :). No info. It probably is though, just a question of when.
December 31 (10 years ago)
vÍnce
Pro
Sheet Author
I get it. Non-disclosure statement. :-)
December 31 (10 years ago)
The Aaron
Pro
API Scripter
Surprisingly, it's more of a gentlemen's agreement.

But regardless, there is no information on the subject. :)
December 31 (10 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Pin him down Vince... pin him down.
December 31 (10 years ago)
The Aaron
Pro
API Scripter
Ha! Can't catch me!!
December 31 (10 years ago)
Flicker light source set to 20/0 and both an orange and yellow aura on the token. Looks very cool. Sadly... auras don't get blocked by dynamic lighting, so they overlap in areas where they shouldn't. Sounds like a suggestion needs to be made to add a checkbox to auras to let them be blocked by dynamic lighting as a toggleable feature.


December 31 (10 years ago)
The Aaron
Pro
API Scripter
Cool!
December 31 (10 years ago)
vÍnce
Pro
Sheet Author
I picked up the Aura trick on the forums somewhere and use it often. [Future Suggestion] Color picker for Emits Light. Just like Auras.
January 01 (10 years ago)
The Aaron
Pro
API Scripter
That would be cool!!
January 01 (10 years ago)
I would rather have rgba support for colors for auras and lighting, so that we can have control over the transparency too.
January 01 (10 years ago)
The Aaron
Pro
API Scripter
I don't think the two are mutually exclusive. Sounds great to me.
January 01 (10 years ago)

Edited January 01 (10 years ago)
SHUT THE FRONT DOOR!!

http://stackoverflow.com/questions/15852122/hex-tr...

Does this actually work in Roll20?!

edit - Dammit... it doesn't work... but I am damn sure gonna make a suggestion to get it added. It should be as simple as increasing the field length of all hex code options to eight, right?
January 01 (10 years ago)
The Aaron
Pro
API Scripter
I'd vote for it. :)
January 01 (10 years ago)
Never mind... it won't work. The ARGB hex code is for the Android system.
January 01 (10 years ago)
https://app.roll20.net/forum/post/1466187/implemen...

Suggestion added. VOTE NOW! VOTE OFTEN! :D

A better color picker would incidentally make scripts like this even more useful.
January 01 (10 years ago)
vÍnce
Pro
Sheet Author

HoneyBadger said:

Never mind... it won't work. The ARGB hex code is for the Android system.
Does that mean the Android-based fork of the new roll20 app could use alpha?

January 01 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

HoneyBadger said:

Never mind... it won't work. The ARGB hex code is for the Android system.

ARGB hex codes work in CSS, just not Roll20.

January 01 (10 years ago)
The Aaron
Pro
API Scripter
So, they should work in something like PowerCards, right Brian?
January 01 (10 years ago)
I don't need 'em for powercards though. I want 'em for tints and auras.
January 31 (10 years ago)
Maybe the script already does this, but can it be modified to change various lighting settings on tokens? There's a use case where the day/night thing might not work as intended, because dynamic lighting can still be used to block LoS in the day. Walls in a well lit building, maybe trees.

Or maybe I'm just not seeing it in the script description, and therefore I apologize for not being a good reader.
January 31 (10 years ago)
The Aaron
Pro
API Scripter
Hi Ari,

This script predates the global illumination setting. I should update it to us that for the daytime setting, great idea!

As for setting individual facets of a token's lighting, it can do that for light radius, dim radius and all players see light.
!torch 60 30 off

Last time I checked, the light multiplier was not available to the API, but I believe it is on dev. I need to update for the new settings.

Hope that helps!