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] One-Way Dynamic Lighting

1492535150

Edited 1492824457
Ada L.
Marketplace Creator
Sheet Author
API Scripter
This script allows you to set up dynamic lighting walls that only block vision on one side. Here's how to use it: Create a path for the wall.&nbsp; Create a filled path for the area from which characters can see through the wall.&nbsp; Select both paths and activate the "OneWayDynamicLighting" macro installed by the script. <a href="https://github.com/Roll20/roll20-api-scripts/tree/" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/</a>... Requires: Path Math&nbsp; Now also available from One-Click! (It's currently listed under the "token" category. I've asked the devs to recategorize it under "dynamic lighting".) Demo:
1492535239
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Oooh, I've been wondering if we could do this via API for a while now. Very nice stephen.
1492535492
The Aaron
Pro
API Scripter
neat. =D
Cool, can't wait to try this out for Leomund's Tiny Hut and to simulate elevations in maps (you can't see over the hill if you are at the bottom but you can from the top.)
My "solution" was to create windows [tiny sliver-shaped tokens] which had Sight and control by the applicable character(s).&nbsp; Clumsy because the players could then accidentally move the windows, so never used it. Do you consider there is a limit to how many one-way lighting sections can be used - and if I do it on several maps in preperation will this cause an issue?
1492541614
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Jim W. said: My "solution" was to create windows [tiny sliver-shaped tokens] which had Sight and control by the applicable character(s).&nbsp; Clumsy because the players could then accidentally move the windows, so never used it. Do you consider there is a limit to how many one-way lighting sections can be used - and if I do it on several maps in preperation will this cause an issue? There isn't a limit to how many one-way walls you can use and it should work just fine across multiple maps.&nbsp;
Scott C. said: Oooh, I've been wondering if we could do this via API for a while now. Very nice stephen. Me too! Time to build cliffs!
Nifty! Thanks for the hard work, Stephen. Looking forward to seeing this in action!
1492574407
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Does this put a higher load on the browser to render?
1492608502
Ada L.
Marketplace Creator
Sheet Author
API Scripter
keithcurtis said: Does this put a higher load on the browser to render? Only as much as normal dynamic lighting does.
Any hope of this getting into one-click soon?
1492819182
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I won't install this so close to game time, but I'd love to see the animated gifs...
1492820735
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ravenknight said: Any hope of this getting into one-click soon? It is in One-Click now, but it looks like whoever processed the pull request categorized it under "token" instead of "dynamic lighting"...
Stephen L. said: Ravenknight said: Any hope of this getting into one-click soon? It is in One-Click now, but it looks like whoever processed the pull request categorized it under "token" instead of "dynamic lighting"... Doh, now I feel silly. Thanks Stephen.
1492823747
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ravenknight said: Stephen L. said: Ravenknight said: Any hope of this getting into one-click soon? It is in One-Click now, but it looks like whoever processed the pull request categorized it under "token" instead of "dynamic lighting"... Doh, now I feel silly. Thanks Stephen. No worries, I asked the devs to recategorize it, but that probably won't be until next week.
1492823802
Ada L.
Marketplace Creator
Sheet Author
API Scripter
keithcurtis said: I won't install this so close to game time, but I'd love to see the animated gifs... The OP now has a demo gif. :)
1492825532
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Stephen, what happens if you have multiple tokens on the board? Will only the token that is in position to see past the DL wall see, or will all tokens be able to see past it?
1492832879
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Stephen L. said: keithcurtis said: I won't install this so close to game time, but I'd love to see the animated gifs... The OP now has a demo gif. :) Thanks, that's much clearer. I probably would have been banging my head against the wall without a visual. That's pretty cool.
1492871260

Edited 1492873305
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Scott C. said: Stephen, what happens if you have multiple tokens on the board? Will only the token that is in position to see past the DL wall see, or will all tokens be able to see past it? All tokens will be able to see past it. Since it works by moving the wall between the GM and DL layers depending on on player tokens' positions, if at least one token is within the viewing area, then the wall will be on the GM layer and therefore everyone can see through it. This is one of the limitations of implementing this through the API. A solution that allows each player token to have their own perspective would require changes to the WebGL code that actually runs the dynamic lighting. I elaborate on this a bit further in the script's readme file. With all this said, only tokens that represent characters and are controlled by players will affect the one-way dynamic lighting walls.So you'll be fine with hiding a bunch of monster/npc tokens up on your ledges and other one-way lighting areas.
This is amazing, bravo man!
Hi guys, I have problem implementing the script into one of my campaigns but not in the others that are using the same scripts. Can any of you tech-savvy people tell me where to look to correct the issue? For reference, the error message generated was: TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined at updateWalls (apiscript.js:21263:44) at token (apiscript.js:21336:5) at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:901:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1368:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)
1493646157

Edited 1493646244
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ravenknight said: Hi guys, I have problem implementing the script into one of my campaigns but not in the others that are using the same scripts. Can any of you tech-savvy people tell me where to look to correct the issue? For reference, the error message generated was: TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined at updateWalls (apiscript.js:21263:44) at token (apiscript.js:21336:5) at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:901:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1368:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) It looks like something is erasing the script's state sometime between when it is initialized and when it tries to update the one-way walls. That, or some bug in the API itself has caused it to skip the 'ready' event handler which initializes the script and its state.
Stephen L. said: Ravenknight said: Hi guys, I have problem implementing the script into one of my campaigns but not in the others that are using the same scripts. Can any of you tech-savvy people tell me where to look to correct the issue? For reference, the error message generated was: TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined TypeError: Cannot read property '-K_fDuXpnWHIChrccK5o' of undefined at updateWalls (apiscript.js:21263:44) at token (apiscript.js:21336:5) at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:901:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1368:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) It looks like something is erasing the script's state sometime between when it is initialized and when it tries to update the one-way walls. That, or some bug in the API itself has caused it to skip the 'ready' event handler which initializes the script and its state. So a messed up state object? I tried to make a new copy with the hope of clearing the problem but it didn't help. Looks like I've got some rebuildning to do.
1493660735
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I created a patched version to try to fix this problem. Let me know if this works:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/blob/O" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/O</a>...
Stephen L. said: I created a patched version to try to fix this problem. Let me know if this works:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/blob/O" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/O</a>... Worked like a charm, Stephen! Thanks so very much.&nbsp;
1493661409
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Great! Give me a shout if you have any other problems with it.
Once a wall is created, how do you say... get rid of it?
1494167174
Ada L.
Marketplace Creator
Sheet Author
API Scripter
B14d3r11 said: Once a wall is created, how do you say... get rid of it? Easy, just delete it from the GM Layer or the Dynamic Lighting layer (whichever it's on at the time).
Stephen L. said: B14d3r11 said: Once a wall is created, how do you say... get rid of it? Easy, just delete it from the GM Layer or the Dynamic Lighting layer (whichever it's on at the time). The area I made with this is neither on the Dynamic lighting layer nor the GM layer but when the token interacts with the area the dynamic lighting updates as if it is still there.
1494172505
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The area is deleted after you create the wall. If you want to change the area, you'll need to delete the line for the wall and make a new one.
Stephen L. said: The area is deleted after you create the wall. If you want to change the area, you'll need to delete the line for the wall and make a new one. Thats the problem though, i've delete everything except the tokens but if my tokens walk into that area it now shows a different lighting as if it was a wall like before...
1494267678
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I've tried to recreate your issue by creating a whole bunch of one-way walls and deleting a bunch of them. It's working as expected for me. When I delete a wall, its area no longer has any sort of effect. Are you getting any sort of stack trace in your API console?
This looks great and I'd love to use it, but I'm getting the following error: "TypeError: Cannot read property 'set' of undefined\n at _.each.wall (apiscript.js:9316:11)\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:158:9)\n at updateWalls (apiscript.js:9305:7)\n at token (apiscript.js:9362:7)\n at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16)\n at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8)\n at TrackedObj.set (/home/node/d20-api-server/api.js:901:14)\n at updateLocalCache (/home/node/d20-api-server/api.js:1194:18)\n at /home/node/d20-api-server/api.js:1378:11\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560" any idea?
1494854484

Edited 1494855101
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Troy S. said: This looks great and I'd love to use it, but I'm getting the following error: "TypeError: Cannot read property 'set' of undefined\n at _.each.wall (apiscript.js:9316:11)\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:158:9)\n at updateWalls (apiscript.js:9305:7)\n at token (apiscript.js:9362:7)\n at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16)\n at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8)\n at TrackedObj.set (/home/node/d20-api-server/api.js:901:14)\n at updateLocalCache (/home/node/d20-api-server/api.js:1194:18)\n at /home/node/d20-api-server/api.js:1378:11\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560" any idea? It looks like at some point one of your dynamic lighting paths was deleted, but it remained in the script's state. I don't know how you wound up in that state, but I can put a fix in for the symptom.&nbsp; Here's a patch for it:&nbsp;<a href="https://github.com/Cazra/roll20-api-scripts/blob/OneWayDynamicLighting/OneWayDynamicLighting/1.0.2/script.js" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/OneWayDynamicLighting/OneWayDynamicLighting/1.0.2/script.js</a>
Stephen L. said: It looks like at some point one of your dynamic lighting paths was deleted, but it remained in the script's state. I don't know how you wound up in that state, but I can put a fix in for the symptom.&nbsp; Here's a patch for it:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/blob/OneWayDynamicLighting/OneWayDynamicLighting/1.0.2/script.js" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/OneWayDynamicLighting/OneWayDynamicLighting/1.0.2/script.js</a> That worked like a charm! Thanks a bunch
Struggling with this one. I have tried the patches restarted and messed about but I dont know what the problem is. Can you help at all? Cheers "ReferenceError: PathMath is not defined\n at createWall (apiscript.js:1432:20)\n at msg (apiscript.js:1589:11)\n at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16)\n at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8)\n at /home/node/d20-api-server/api.js:1510:12\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)\n at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)\n at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)\n at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)"
1499263031
The Aaron
Pro
API Scripter
You need to install the prerequisite Path Math script from the repo. &nbsp;The script is in 1-click now, so installing it from there should install the dependency automatically.