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

PLACE LIGHT default scale (and by extension, automatic rescaling of all imperial indications)

Hi all, is there a way to change the default scale of the place light tool? All my measurements, maps and all always need to be rescaled because of the use of metric system.  À grid square is always 1.5m in my games, and I constantly have to resale any light objects, any dragged object or token emitting light or vision distances to rescqle it.  Could there be a way of, when scaling the map, automatically adapt all these distances?  Thanks 
1634568026
The Aaron
Roll20 Production Team
API Scripter
I created a script to handle this, but I just noticed you don't have the Pro flag.  If I remember correctly, you have access to Pro features in your games, so here's a script I'm calling AdjustLightTool.  With this script installed, when you place a light with the Light Tool, it will do 3 things: RESIZE -- it will resize the light token to be the size of a grid square.  Generally, that's 70x70, but if your squares are larger or smaller, it will adjust. SNAP -- it will snap the light to the grid square.  If you have RESIZE on, it will end up filling the square. SCALE -- it will adjust the bright and dim light to the scale of the map, based on ( Grid Cell Distance / 5).  So if your Grid Cell Distance is 1.5m, it will adjust from 20ft to 6m. You can turn all of those off by changing the true next to them in the code to a false . The code: on('ready',()=>{ const RESIZE = true; const SNAP = true; const SCALE = true; on('add:graphic',(obj)=>{ if(/torch.svg$/.test(obj.get('imgsrc'))){ const props = {}; const page = getObj('page',obj.get('pageid')); let gridsize = 70*(page.get('snapping_increment')||1); const r = (p)=> props.hasOwnProperty(p) ? props[p] : obj.get(p); if(RESIZE){ let w = r('width'); let h = r('height'); let l = r('left'); let t = r('top'); props.left = l - (w/2) + (gridsize/2); props.top = t - (h/2) + (gridsize/2); props.width = gridsize; props.height = gridsize; } if(SNAP) { let w = r('width'); let h = r('height'); let l = r('left'); let t = r('top'); props.left = (Math.floor(l/gridsize)*gridsize)+(w/2); props.top = (Math.floor(t/gridsize)*gridsize)+(h/2); } if(SCALE) { let s = page.get('scale_number')/5; let bl = r('bright_light_distance'); let ll = r('low_light_distance'); props.bright_light_distance = bl*s; props.low_light_distance = ll*s; } obj.set(props); } }); });
1634654372
The Aaron
Roll20 Production Team
API Scripter
This could probably be expanded to tokens dragged onto the map, though it would be hard to know if they'd already been converted.
Yeah... we'd have to select the token once dragged and then click on a macro to convert it. What would be the issue doing this ? we should only rescale tokens on the token layer, not in compendium nor in journals. If this could be done that'd be great. Thank you for giving a glimpse of thoughts for the old continent players haha
1634657060
The Aaron
Roll20 Production Team
API Scripter
The above script will work for the Light Tool out of the box.  For tokens, if you know that any token placed on the token layer needs to be rescaled, that could be done pretty easily.  The problem will be with tokens that are the default tokens for characters in the Journal.  There probably isn't a way to tell the difference between them and compendium tokens.  I'll give some thought to it, perhaps we can mark converted tokens in some way so they can be ignored.  Or possibly we can track what characters were just created in the journal and only convert the first token for them.  That would probably work if the token is being pulled from the compendium and results in the creation of a token on the map and a character in the journal in one go.  Hmm...   I'll have to test that...
1634657376
The Aaron
Roll20 Production Team
API Scripter
Yeah, looking at characters created followed by tokens created seems like it could work.  I'll try and throw that together tonight.
I think that if you "convert" a charcater that has just been dropped from journal or from compendium, it works. I don't mind doing that on every dragged token once in the game. The biggest issue is once we open a new map (as an add on or something from market place)we have to do that for eveytoken and/or source light. Maybe with a selection of all tokens on gm/token/DL layer and a click on the macro can cenvert a full map to what we need. i think scriptcard can do this mass selection no ?
1634658798
The Aaron
Roll20 Production Team
API Scripter
So, an example of the workflow you're talking about would be: Add imperial unit based Addon to the game Change Page 's Grid Cell Distance from 5 -> 1.5 , change units from ft -> m Fix all tokens populating the map to be in m instead of ft . Sound right?  I think I could make that a single command.
Yup that'd be perfect. And if later on we need to add one or more tokens we can drag and drop them, select them and convert them 
1634662170
The Aaron
Roll20 Production Team
API Scripter
Provided you're dragging them from the compendium for the first time, I can probably fix that automatically.  =D
1634667633
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: I created a script to handle this, but I just noticed you don't have the Pro flag.  If I remember correctly, you have access to Pro features in your games, so here's a script I'm calling AdjustLightTool.  With this script installed, when you place a light with the Light Tool, it will do 3 things: RESIZE -- it will resize the light token to be the size of a grid square.  Generally, that's 70x70, but if your squares are larger or smaller, it will adjust. SNAP -- it will snap the light to the grid square.  If you have RESIZE on, it will end up filling the square. SCALE -- it will adjust the bright and dim light to the scale of the map, based on ( Grid Cell Distance / 5).  So if your Grid Cell Distance is 1.5m, it will adjust from 20ft to 6m. That's a handy script up there, Aaron. It basically fixes the code that the light tool should have in the first place...
1634669847
The Aaron
Roll20 Production Team
API Scripter
Yeah, if I actually used the Light Tool, I'd probably use it with this script.  I find dragging preconfigured tokens out of the journal more useful.
The Aaron said: Provided you're dragging them from the compendium for the first time, I can probably fix that automatically.  =D It can be from the compendium or from the add on's journal monsters.
1634677388
The Aaron
Roll20 Production Team
API Scripter
Compendium I can definitely handle.  If the journal characters are on a converted page, my intent would be to set the default token when I do a conversion, so that would fix them as long as you fixed the page they were on.
1634687273
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: Yeah, if I actually used the Light Tool, I'd probably use it with this script.  I find dragging preconfigured tokens out of the journal more useful. Yeah, I use a utility token that has a  Chat Menu  for changing it into a light source, a light crumb, a note token, a map key, etc.