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] Light-Crumb Trail (to let players see where they've been with dynamic lighting on)

1483985846
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
plexsoup said: Regarding the whisper, I'll try and change it so it only whispers to the gm when the gm joins the game (and not the other players). I can definitely add a button to disable that feature. I might suggest just having the help be user triggered rather than having it be a message that is displayed to the GM every time they log in. If it displays every time they log in, they could get it multiple times in a session if they have to reload the tabletop for lag issues/video&voice issues.
1483986509
Pat S.
Forum Champion
Sheet Author
Scott C. said: plexsoup said: Regarding the whisper, I'll try and change it so it only whispers to the gm when the gm joins the game (and not the other players). I can definitely add a button to disable that feature. I might suggest just having the help be user triggered rather than having it be a message that is displayed to the GM every time they log in. If it displays every time they log in, they could get it multiple times in a session if they have to reload the tabletop for lag issues/video&voice issues. I agree with Scott on this. I run text based games and I would rather not have it constantly showing up in the log when I hop into the game mutliple times to work on stuff that does not even involve the use of the script.
Is it possible to get this to view terrain only?  While I can have my monsters talk the PCs on the GM layer, it'd simplify my life to keep doing it on the token layer. Thank you very much for this; I'll be sure to give it a go after 1 click install is done.
1483992656
The Aaron
Pro
API Scripter
Not possible with the API.  You could write a script (like bump) that automatically pushes non-PCs to the GM layer if they are moved into the range of a dropped light source.  That might get a bit complicated and possibly confusing.
1483995887

Edited 1483996038
plexsoup
Marketplace Creator
Sheet Author
API Scripter
I could make NPC tokens invisible (transparent icon with an aura only visible to the GM), but I can't make them reappear unless their images were uploaded by the user. (Set imgsrc restriction in the api.) If Roll20 devs could make set imgsrc work for marketplace assets, we could store the imgsrc, set a status and aura, make them transparent, then change them back to original when the status changes. Bump is probably a better way to go.
1483997032
The Aaron
Pro
API Scripter
That has been on the API promised list for at least 2 gencons... I harass Riley about it every time I see him. =D (sorry Riley!)
1484125217
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Something's gone wrong. I might need some help. When i drop tokens, the light doesn't show up. If I look at the token details, they appear to have all the correct settings for light radius and dim light radius. If I then select the (unlit) tokens on the map, they suddenly start emitting light. Here's a&nbsp; video of the strange behaviour in action . Strangely, I haven't noticed this behaviour before now. So I don't think the dropped light-crumbs were misbehaving on previous versions. (I haven't updated the original Gist because the new version is borked. Here's a link to the&nbsp; broken version .) Anyone have any ideas? Here's the relevant section of code: currentLightCrumb = createObj('graphic',{ imgsrc: config.IMAGE, subtype: 'token', pageid: currentPage, width: size, height: size, left: targetLocation[0], top: targetLocation[1], light_radius: config.LIGHT_RADIUS, light_dimradius: config.DIM_RADIUS, light_hassight: true, light_otherplayers: true, controlledby: "all", layer: 'objects', isdrawing: true }); log( "dropped brand new currentLightCrumb: " + JSON.stringify(currentLightCrumb) ); ----------------- LOG: "dropped brand new currentLightCrumb: {\"_id\":\"-KaBgkV5eGItZbk7yyIb\",\"_pageid\":\"7F73B956-71C3-4C5B-8C72-576EE4F15EA4\",\"left\":\"595\",\"top\":\"1085\",\"width\":35,\"height\":35,\"rotation\":0,\"layer\":\"objects\",\"isdrawing\":true,\"flipv\":false,\"fliph\":false,\"imgsrc\":\"<a href="https://s3.amazonaws.com/files.d20.io/images/17247606/Wbr841_bq9ka1FmamWo38w/thumb.png?1458169656\&quot;,\&quot;name\&quot;:\&quot;\&quot;,\&quot;gmnotes\&quot;:\&quot;\&quot;,\&quot;controlledby\&quot;:\&quot;all\&quot;,\&quot;bar1_value\&quot;:\&quot;\&quot;,\&quot;bar1_max\&quot;:\&quot;\&quot;,\&quot;bar1_link\&quot;:\&quot;\&quot;,\&quot;bar2_value\&quot;:\&quot;\&quot;,\&quot;bar2_max\&quot;:\&quot;\&quot;,\&quot;bar2_link\&quot;:\&quot;\&quot;,\&quot;bar3_value\&quot;:\&quot;\&quot;,\&quot;bar3_max\&quot;:\&quot;\&quot;,\&quot;bar3_link\&quot;:\&quot;\&quot;,\&quot;represents\&quot;:\&quot;\&quot;,\&quot;aura1_radius\&quot;:\&quot;\&quot;,\&quot;aura1_color\&quot;:\&quot;#FFFF99\&quot;,\&quot;aura1_square\&quot;:false,\&quot;aura2_radius\&quot;:\&quot;\&quot;,\&quot;aura2_color\&quot;:\&quot;#59E594\&quot;,\&quot;aura2_square\&quot;:false,\&quot;tint_color\&quot;:\&quot;transparent\&quot;,\&quot;statusmarkers\&quot;:\&quot;\&quot;,\&quot;showname\&quot;:false,\&quot;showplayers_name\&quot;:false,\&quot;showplayers_bar1\&quot;:false,\&quot;showplayers_bar2\&quot;:false,\&quot;showplayers_bar3\&quot;:false,\&quot;showplayers_aura1\&quot;:false,\&quot;showplayers_aura2\&quot;:false,\&quot;playersedit_name\&quot;:true,\&quot;playersedit_bar1\&quot;:true,\&quot;playersedit_bar2\&quot;:true,\&quot;playersedit_bar3\&quot;:true,\&quot;playersedit_aura1\&quot;:true,\&quot;playersedit_aura2\&quot;:true,\&quot;light_radius\&quot;:\&quot;15\&quot;,\&quot;light_dimradius\&quot;:\&quot;5\&quot;,\&quot;light_otherplayers\&quot;:true,\&quot;light_hassight\&quot;:true,\&quot;light_angle\&quot;:\&quot;\&quot;,\&quot;light_losangle\&quot;:\&quot;\&quot;,\&quot;light_multiplier\&quot;:1,\&quot;sides\&quot;:\&quot;\&quot;,\&quot;currentSide\&quot;:0,\&quot;lastmove\&quot;:\&quot;\&quot;,\&quot;_type\&quot;:\&quot;graphic\&quot;,\&quot;_subtype\&quot;:\&quot;token\&quot;,\&quot;_cardid\&quot;:\&quot;\" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/17247606/Wbr841_bq9ka1FmamWo38w/thumb.png?1458169656\",\"name\":\"\",\"gmnotes\":\"\",\"controlledby\":\"all\",\"bar1_value\":\"\",\"bar1_max\":\"\",\"bar1_link\":\"\",\"bar2_value\":\"\",\"bar2_max\":\"\",\"bar2_link\":\"\",\"bar3_value\":\"\",\"bar3_max\":\"\",\"bar3_link\":\"\",\"represents\":\"\",\"aura1_radius\":\"\",\"aura1_color\":\"#FFFF99\",\"aura1_square\":false,\"aura2_radius\":\"\",\"aura2_color\":\"#59E594\",\"aura2_square\":false,\"tint_color\":\"transparent\",\"statusmarkers\":\"\",\"showname\":false,\"showplayers_name\":false,\"showplayers_bar1\":false,\"showplayers_bar2\":false,\"showplayers_bar3\":false,\"showplayers_aura1\":false,\"showplayers_aura2\":false,\"playersedit_name\":true,\"playersedit_bar1\":true,\"playersedit_bar2\":true,\"playersedit_bar3\":true,\"playersedit_aura1\":true,\"playersedit_aura2\":true,\"light_radius\":\"15\",\"light_dimradius\":\"5\",\"light_otherplayers\":true,\"light_hassight\":true,\"light_angle\":\"\",\"light_losangle\":\"\",\"light_multiplier\":1,\"sides\":\"\",\"currentSide\":0,\"lastmove\":\"\",\"_type\":\"graphic\",\"_subtype\":\"token\",\"_cardid\":\"\</a>"}"
1484140779
The Aaron
Pro
API Scripter
That's super strange. &nbsp;I would suggest restarting your browser. &nbsp;I tried the linked script and it is working fine for me. &nbsp;A display issue like that is almost certainly on the client side (browser), rather than the server side (API).&nbsp;
1484148010

Edited 1484149491
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I see from the TODO list in your script's comments that you're looking for some occlusion code for handling line-of-sight to the breadcrumbs. I do this for checking line-of-sight to traps in my It's A Trap script. Check out the below snippet from It's A Trap: ... /** * Gets the tokens that a token has line of sight to. * @private * @param {Graphic} token * @param {Graphic[]} otherTokens * @param {number} [range=Infinity] * The line-of-sight range in pixels. * @param {boolean} [isSquareRange=false] * @return {Graphic[]} */ function _getTokensInLineOfSight(token, otherTokens, range, isSquareRange) { if(_.isUndefined(range)) range = Infinity; var pageId = token.get('_pageid'); var tokenPt = [ token.get('left'), token.get('top'), 1 ]; var tokenRW = token.get('width')/2-1; var tokenRH = token.get('height')/2-1; var wallPaths = findObjs({ _type: 'path', _pageid: pageId, layer: 'walls' }); var wallSegments = PathMath.toSegments(wallPaths); return _.filter(otherTokens, other =&gt; { var otherPt = [ other.get('left'), other.get('top'), 1 ]; var otherRW = other.get('width')/2; var otherRH = other.get('height')/2; // Skip tokens that are out of range. if(isSquareRange && ( Math.abs(tokenPt[0]-otherPt[0]) &gt;= range + otherRW + tokenRW || Math.abs(tokenPt[1]-otherPt[1]) &gt;= range + otherRH + tokenRH)) return false else if(!isSquareRange && VecMath.dist(tokenPt, otherPt) &gt;= range + tokenRW + otherRW) return false; var segToOther = [tokenPt, otherPt]; return !_.find(wallSegments, wallSeg =&gt; { return PathMath.segmentIntersection(segToOther, wallSeg); }); }); } ...
1484152727
plexsoup
Marketplace Creator
Sheet Author
API Scripter
The Aaron said: That's super strange. &nbsp;I would suggest restarting your browser. &nbsp;I tried the linked script and it is working fine for me. &nbsp;A display issue like that is almost certainly on the client side (browser), rather than the server side (API).&nbsp; That makes sense. I'll give it another go. Thanks. Stephen L. said: I see from the TODO list in your script's comments that you're looking for some occlusion code for handling line-of-sight to the breadcrumbs. I do this for checking line-of-sight to traps in my It's A Trap script Sweet! Thanks. I'll definitely incorporate this.
1484155026
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Go right ahead! Just note that the snippet requires both PathMath and VecMath.
1484301438
plexsoup
Marketplace Creator
Sheet Author
API Scripter
plexsoup said: Something's gone wrong. I might need some help. When i drop tokens, the light doesn't show up. If I look at the token details, they appear to have all the correct settings for light radius and dim light radius. If I then select the (unlit) tokens on the map, they suddenly start emitting light. Here's a&nbsp; video of the strange behaviour in action Found my bug! For anyone curious... var movementPath = token.get("lastmove"); &nbsp;// produces a string of comma delimited numbers. var travelLocationsArray = token.get("lastmove").split(","); // produces an array of strings, not numbers. //var X = travelLocationsArray[0]; // is a string. var X = Number(travelLocationsArray[0]); // works better // don't try creating dynamically lit objects with strings as parameters for "left" and "top".&nbsp;They'll go where you expect, but won't be lit until moved.
1484303264
plexsoup
Marketplace Creator
Sheet Author
API Scripter
The Gist is updated... torches now appear at the token's last known location, instead of their current one.&nbsp; Should solve problems with torches appearing on top of characters, and also torches appearing on the other side of walls.
1484311041
Pat S.
Forum Champion
Sheet Author
Goofing around with the script and noticed something. I get nothing from the GUI if I'm using the talktomyself function.
1484315534
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Pat S. said: Goofing around with the script and noticed something. I get nothing from the GUI if I'm using the talktomyself function. Yep, API commands don't work with /talktomyself as the chat message is not sent anywhere besides the dice roller.
1484316539
Pat S.
Forum Champion
Sheet Author
I figured that but since I don't use it much, I thought I might mention it.
1484317048
The Aaron
Pro
API Scripter
plexsoup said: plexsoup said: Found my bug! For anyone curious... var movementPath = token.get("lastmove"); &nbsp;// produces a string of comma delimited numbers. var travelLocationsArray = token.get("lastmove").split(","); // produces an array of strings, not numbers. //var X = travelLocationsArray[0]; // is a string. var X = Number(travelLocationsArray[0]); // works better // don't try creating dynamically lit objects with strings as parameters for "left" and "top".&nbsp;They'll go where you expect, but won't be lit until moved. Interesting! &nbsp;parseFloat() or parseInt() are what I'd usually use to convert from a string. &nbsp;Technically you shouldn't instance a class like Number without the new operator.
1484396738
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Some updates: You can now decide whether lightcrumbs will have shared vision, or unique vision for the player who dropped them. I haven't tested the unique vision with a group. Let me know if it behaves as expected. (Changing the vision sets the "controlledby" parameter on the token, by adding or removing "all players".) I've also reincorporated optional offsets. You can decide whether you prefer dropping the lightcrumbs at the token's last location or the current location plus some directional offset. (I think the offset looks cooler, but I understand how it might penetrate walls now and then.) Now that each character can have their own trail, Crumbs are identified with the character's initials. You can toggle name displays to make it a bit easier to identify who owns which trail. <a href="https://gist.github.com/plexsoup/64852540504101b52" rel="nofollow">https://gist.github.com/plexsoup/64852540504101b52</a>...
1484397665
Kryx
Pro
Sheet Author
API Scripter
Making the case again for the vision based on the current token: This feature is basically Blizzard style fog of war. In games that incorporate fog of war the vision that is left is based on the unit that gave the vision. For example in Starcraft an Overlord who is flying gives a much large vision radius than a burrowed zergling. For that reason I'd encourage you to base the vision of the light object on the token from which it originates.
1484430910
plexsoup
Marketplace Creator
Sheet Author
API Scripter
I'll work on that next, Kryx
1484489246

Edited 1484513391
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Added a few things, including inherited light settings per Kryx. <a href="https://gist.github.com/plexsoup/64852540504101b52" rel="nofollow">https://gist.github.com/plexsoup/64852540504101b52</a>... There's a couple of little gremlins, but it works ok for the most part. Next priority is bugfixing. Then maybe refactoring. Video in action
Love that script! Any chance it will be part of the roll20-api-scripts repository?
1484518655
Kryx
Pro
Sheet Author
API Scripter
Thanks for doing that plex. I'll be sure to get it running for my game on Tuesday and report back.
1484525239

Edited 1484525266
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Arthur B said: Love that script! Any chance it will be part of the roll20-api-scripts repository? Eventually. But first I need to seriously test it for bugs. I'd hate to release it as 1-click and have everyone mad cause it breaks. You can help by... testing it for bugs.
1484531756
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
plexsoup said: Eventually. But first I need to seriously test it for bugs. I'd hate to release it as 1-click and have everyone mad cause it breaks. Can attest that this sucks to do
1484557157
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Got a few bugs fixed. The revised script is at&nbsp; the same address . Let me know if it works for you.
plexsoup said: Arthur B said: Love that script! Any chance it will be part of the roll20-api-scripts repository? Eventually. But first I need to seriously test it for bugs. I'd hate to release it as 1-click and have everyone mad cause it breaks. You can help by... testing it for bugs. Ah, I'm doing that right now. Testing, I mean. I'm spamming my map with torches right now. But I'm actually not (yet) talking about a 1-click installation. I'd just like to have it as part of the roll20 repository on github. I have a script that combines all the scripts that I'm using into one, and it's taking the original scripts directly from the cloned repository (the script triggers a git pull before). So I always have the newest scripts in one big file, without manual work. :)
1484603507
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Ah. Yeah. I can probably do that.
1484728548
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Hopefully it's working well for people in actual games. I've submitted a pull request to the API repository for 1-click. In the meantime, you can still grab it from the&nbsp; same old gist . Latest version just changed the help document and reorganized the config options a bit.
To answer the question of: would it be cool if they burnt out over time? &nbsp;Hell yes! &nbsp;Any luck on getting them visible only to the player that dropped them?
1484850719

Edited 1484850888
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Sudain said: Any luck on getting them visible only to the player that dropped them? Yes. By default, players only see through their own torches, but if you click "Toggle Shared Vision", it should switch to a mode where players see through everyone's torches. You can verify be looking at one of the torches. It'll be controlled either by the player, or by "all players". &nbsp; Players can still see each other's torches when they're not hidden by walls. I might need to tweak the "all players see light" setting.
Sweetness! &nbsp;:)
1484863902

Edited 1484864403
plexsoup
Marketplace Creator
Sheet Author
API Scripter
I've just updated it. In the latest version, torches only cast light to the players who made them. (Unless you turn on Shared Vision mode). <a href="https://gist.github.com/plexsoup/64852540504101b52" rel="nofollow">https://gist.github.com/plexsoup/64852540504101b52</a>... Please let me know if you have any problems with the script. Errors, confusion, feature requests, whatever.
1484914137
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Grab the new script to avoid a bug where it broke if no character was assigned to the registered token.&nbsp; <a href="https://gist.github.com/plexsoup/64852540504101b52" rel="nofollow">https://gist.github.com/plexsoup/64852540504101b52</a>...
1484950653

Edited 1484950664
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Updated again to fix a couple more edge cases. Same URL
Awesome, thank you.
1485164044
plexsoup
Marketplace Creator
Sheet Author
API Scripter
New video shows the latest GUI
The&nbsp;LightCrumb API is in the&nbsp;Roll20 API Script Library but when I installed it if does not work. &nbsp;When I type !LightCrumb nothing happens. Any ideas?
1485748575

Edited 1485748601
plexsoup
Marketplace Creator
Sheet Author
API Scripter
The script.json had a typo in it. So the 1-click version doesn't work yet. For now, just make a new script and cut and paste the text of the script from the gist. <a href="https://gist.github.com/plexsoup/64852540504101b52" rel="nofollow">https://gist.github.com/plexsoup/64852540504101b52</a>... It may be a few weeks before the 1-click version works.
Hey, @plexsoup. I added an option to the script to change the size of the aura, which I think would be useful to others as well. Could you take a look at it and maybe add the changes to your script? <a href="https://gist.github.com/Tritlo/fd26b55bba363ef0dc2ef26ccde28b7b" rel="nofollow">https://gist.github.com/Tritlo/fd26b55bba363ef0dc2ef26ccde28b7b</a>
1486466800
plexsoup
Marketplace Creator
Sheet Author
API Scripter
Awesome! Sounds like a good addition.&nbsp;I'll take a look.
1486469921
plexsoup
Marketplace Creator
Sheet Author
API Scripter
I posted your changes back to my Gist and tweaked the units slightly.