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

API Request (or perhaps it exists?)

1664506988
Not sure if this would be an easy one for coders to do, and forgive me if it already exists! I have a gloom stalker ranger and a shadow monk, both of whom have abilities that are triggered/impacted by their presence in either dim or bright light. As it happens, I'm constantly measuring against the light source to see just how far it's reaching, etc., and since I'm running DotMM, it's not like I can easily go in and manually add auras to each lightsource. Could one foresee an API that would add a visible aura on the map layer (or DM layer) to static light sources on the lighting layer, with gradation between the bright and dim reach? I think for the sake of ease, something that automatically applied the standard 20 and 20 of a torch to each light source would be just fine.
1664510993

Edited 1664511227
Oosh
Sheet Author
There's a complication there with 5e's silly geometry. Namely that R20 light sources are round which means with 5e's geometry (diagonals on squares are equal to the square's sides) their diagonal light doesn't travel as far as their cardinal light. Essentially, light sources should be square for 5e so they're emitting light the same range in each direction. You can see this if you pull out a ruler on a 20ft light source. It'll only reach around 15ft on the diagonals. This means you can either: 1. Calculate the light range properly according to 5e RAW using squares. This won't align with what players can actually see and may cause confusion if they're diagonally positioned from a nearby light source. 2. Calculate the light range properly according to Euclidean geometry. This will match what players can see, but won't be following the same rules as things like movement & weapon ranges according to 5e RAW. 3. Calculate the light range properly according to Euclidean geometry and scrap 5e's lazy geometry since you're on a VTT with a ruler. Then everything makes sense, but you'll need to use the ruler a lot.
1664550856
The Aaron
Forum Champion
API Scripter
Definition of light aside, writing a script to determine if a token is in bright or dim light would not be impossible.  The major challenge would be figuring out which squares are actually dim light.  There isn't a function in the Mod Sandbox that lets you query that, so you'd need to calculate it based on each light source and the set of walls.  one-way and transparent walls makes that slightly challenging.  Also, you'd need to recalculate or adjust whenever either a wall is moved (doors opened or closed, windows opened, etc), or when a light source moves (token with light, or something automated on the DL layer...).  You'd also need to pay attention to the global illumination.
1664572003
Got it. Well, let's say we made it a bit easier, since we don't need the perfect to stand in the way of the good. What if all we did was just give each light source token a double aura, using the standard roll20 aura mechanism... and as long as the two auras were visible to the DM while he or she is on the object layer, the DM could then make the judgment call as to whether a particular PC token was in it or out of it (easy enough to do using the 5E rule that an AoE cutting through half or more of a square is considered to affect that square). Similarly, the DM would have to make the judgment call regarding walls and whether or not the aura would actually be light or not. I'd be more than happy with that "problem." More than anything, I just wish there were visible (to me only) 20/20 auras on light sources.
1664572159
Craig M. said: Got it. Well, let's say we made it a bit easier, since we don't need the perfect to stand in the way of the good. What if all we did was just give each light source token a double aura, using the standard roll20 aura mechanism... and as long as the two auras were visible to the DM while he or she is on the object layer, the DM could then make the judgment call as to whether a particular PC token was in it or out of it (easy enough to do using the 5E rule that an AoE cutting through half or more of a square is considered to affect that square). Similarly, the DM would have to make the judgment call regarding walls and whether or not the aura would actually be light or not. I'd be more than happy with that "problem." More than anything, I just wish there were visible (to me only) 20/20 auras on light sources. You could use the TokenCondition script to add an invisible .png token to each light source, and add the double aura that is only visible to the GM to that token.
1664577994
Yes, that's the manual method, but I would have to do it by hand for each light source on the map, which is a non-starter for me. So I'm imagining a script that would scan the DL layer for light sources and add these magical auras for me. A boy can dream. ;)
1664580321

Edited 1664772733
Oosh
Sheet Author
UPDATED: The script will now do dynamic wall calculations. I think the only thing left is one-way walls, but DoTMM pre-dates their existence so presumably there's none in there anyway. This script now requires the Path Math script from the one-click. Here's a start on it. Just use !checkLight (not case-sensitive) with a token selected. It doesn't do wall intersects yet, I haven't used Roll20 since one-way walls went in so I'm not really sure how to deal with that part. It also doesn't check global illumination yet, but that's pretty simple. See if it does what you want though, bearing those two missing parts in mind: - SNIP - The script has moved to this thread and this repo.
1664586278
WHOA. That's amazing! THANK YOU SO MUCH!
1664591587

Edited 1664592339
Oosh
Sheet Author
Updated - the script should now account for blocking walls and global illumination, but it now requires the Path Math script from the one-click. I also tidied up the output a wee bit: Let me know if there's any issues. Some of the Mad Mage maps are pretty big, no idea how performant the wall intesect method is.
1664591976
Holy geez... you're fantastic for this! I appreciate it so much.
1664592379

Edited 1664593423
Oosh
Sheet Author
I just did another minor update to fix some formatting issues, and changed the version at the top to 0.2.0 so you know if you've got the right one! edit - Oh, I should probably add that the LOS check is only a simple center-to-center check, so you'll have to call edge cases manually. And let me know if you do need the one-way wall functionality, as it shouldn't be too hard to add.
Wow that opens probably a lot of possibilities once this result can be retrieved and interpreted by other scripts. 
1664824509
I don't know who makes the decisions to include stuff in the one-click API library, but this deserves to be in there for sure.
1664829137
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Craig M. said: I don't know who makes the decisions to include stuff in the one-click API library, but this deserves to be in there for sure. It's done at the request of the author. So long as they meet the (not-terribly strict) standards of Roll20, if the author submits and asks, they are included.
1664867696

Edited 1664868691
Oosh
Sheet Author
It could potentialy make it in there - definitely needs a bit more work first, though. I'll keep playing around with it over here , I'm sure there are a bunch more bugs to sort out.