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

Handling Doors With Dynamic Lighting

1525135844

Edited 1525136431
MyRoll20Stuffs
API Scripter
I've been thinking of ways to handle opening / closing doors with dynamic lighting involved and I think I came up with a solution I just need some help. Do dynamic lighting polygon lines have an object ID like all other objects / tokens / graphics? Here's an example of how I have a door set up: The red line is what will be moved to a different location or layer when the door is opened and the door itself will be moved from the map layer to the gmlayer. My question is this: Without any additional API scripts and just using TokenMod is it possible for me to keep the door on the token layer and to store the ID of the dynamic lighting polygon in bar1 of the door. Then with TokenMod move the ID stored in bar1 from dynamic lighting layer to gm layer and move the door from token layer to gm layer? That way I could store all my dynamic lighting polygon IDs in the doors bar1 attribute and just have an open and close macro where I select the door while on the appropriate layer and it will move the dynamic lighting polygon and door graphic to the proper layers whether I click the open macro or close macro. Can someone show me what I would have to type up using TokenMod to achieve this? EDIT: I also have the "ChatSetAttr" and "ShowAttr" API scripts installed. Could either of these be combined with TokenMod to achieve the results I want?
1525138437

Edited 1525138504
GiGs
Pro
Sheet Author
API Scripter
Since you're a Pro user, you may find the ScarioSwitcher plugin useful Script thread:&nbsp; <a href="https://app.roll20.net/forum/post/6217778/script-s" rel="nofollow">https://app.roll20.net/forum/post/6217778/script-s</a>... Guide thread: <a href="https://app.roll20.net/forum/post/6223040/guide-sc" rel="nofollow">https://app.roll20.net/forum/post/6223040/guide-sc</a>... A video showing what it's for: <a href="https://www.youtube.com/watch?v=hmULjEdofWU" rel="nofollow">https://www.youtube.com/watch?v=hmULjEdofWU</a> (Dynamic Lighting being used for exactly what you want, starts around 3:10). This script uses the token bars in the same way you are asking about, so it should be pretty easy for you to grasp how to use it.
Thanks for the reply. That's a great script but I was hoping to come to a solution without adding any additional complicated scripts to my setup and do it by just using TokenMod.
I figured out how to open the door using TokenMod like I wanted: Open Door Macro !token-mod --set layer|gmlayer --ids {@selected|bar1} !token-mod --set layer|gmlayer --ids {@selected|token_id} Just have a question. What is the dynamic lighting layer called within TokenMod? dllayer? dynamiclayer? When I want to close the door again what do I put in this: !token-mod --set layer|[dynamic lighting layer name]--ids {@selected|bar1}
Let me know how this winds up. I really would like to have a way to open a door and let the dynamic lighting illuminate the room, but stop doing so when the door is closed.
1525140406

Edited 1525140713
MyRoll20Stuffs
API Scripter
So I found out the layer name is "walls" so I try it hard coded with the ID of the dynamic lighting polygon: Open Door: !token-mod --set layer|gmlayer --ids -LBOQy47cHuOZuB-npB5 And: Close Door: !token-mod --set layer|walls --ids -LBOQy47cHuOZuB-npB5 And nothing happens when running either macro. Can someone else test this and tell me what I'm doing wrong? EDIT: When I select the Door Graphic on the Token Layer and run Open Door and Close Door macros it moves the door to gmlayer then to walls - it's like it is ignoring --ids and only taking action on whatever is selected. Please someone help me I'm stumped here.
1525140557
The Aaron
Pro
API Scripter
TokenMod only works on tokens. I’ve thought about adding support for Paths and Text objects, but have not done so yet.&nbsp;
The Aaron said: TokenMod only works on tokens. I’ve thought about adding support for Paths and Text objects, but have not done so yet.&nbsp; Why does it need support added? That's what I don't understand. The dynamic lighting polygon is an object with an ID just like any other graphic correct?
1525142423

Edited 1525142566
GiGs
Pro
Sheet Author
API Scripter
Kastion said: The Aaron said: TokenMod only works on tokens. I’ve thought about adding support for Paths and Text objects, but have not done so yet.&nbsp; Why does it need support added? That's what I don't understand. The dynamic lighting polygon is an object with an ID just like any other graphic correct? Drawing objects aren't quite the same as Tokens. If you right-click them, you can't assign a character to them, add status markers, or do any of the other things you can do with tokens. They are separate class of graphic objects. I'd assume tokenMod applies only to tokens, specifically because most of the features tokenMod offers are only useful to tokens. Also, when you choose a group of objects (using selected), you don't accidentally change things on non-token objects too.
I REALLY wanted this functionality bad. SO bad I wrote a script called moveLighting to move dynamic lighting polygon objects to different layers: // By:&nbsp; &nbsp; &nbsp; &nbsp;Kastion // Contact:&nbsp; <a href="https://app.roll20.net/users/3173313/kastion" rel="nofollow">https://app.roll20.net/users/3173313/kastion</a> var moveLighting = moveLighting || (function(){ &nbsp; &nbsp; 'use strict'; var showHelp = function() { &nbsp; &nbsp; &nbsp; &nbsp; sendChat('Move Lighting Script', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/w gm '+ '&lt;div style="border: 1px solid black; background-color: white; padding: 3px 3px;"&gt;'+ '&lt;div style="font-weight: bold; border-bottom: 1px solid black;font-size: 130%;"&gt;'+ 'moveLighting'+ '&lt;div style="clear: both"&gt;&lt;/div&gt;'+ '&lt;/div&gt;'+ '&lt;div style="padding-left:10px;margin-bottom:3px;"&gt;'+ '&lt;p&gt;Allows the GM to move what layer a lighting path is on.&lt;/p&gt;'+ '&lt;/div&gt;'+ '&lt;b&gt;Commands&lt;/b&gt;'+ '&lt;div style="padding-left:10px;"&gt;&lt;b&gt;&lt;span style="font-family: serif;"&gt;!movelight [layer] [ID]&lt;/span&gt;&lt;/b&gt;'+ '&lt;div style="padding-left: 10px;padding-right:20px; font-size:12px;"&gt;'+ 'Valid Layer Options Are: map, objects, gmlayer, walls'+ '&lt;/div&gt;'+ '&lt;/div&gt;' &nbsp; &nbsp; &nbsp;); &nbsp; &nbsp; }, &nbsp; &nbsp;&nbsp; handleInput = function(msg) { if ( "api" !== msg.type || !playerIsGM(msg.playerid) ) { return; } &nbsp; &nbsp; &nbsp; &nbsp; let parts = msg.content.split(/\s+--\s+/); let args = parts[0].split(/\s+/); switch(args[0]) { case '!movelight': { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var valid_layer = 0, new_layer = args[1]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (new_layer) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case "gmlayer": &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case "walls": &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case "objects": &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case "map": &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valid_layer = 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (valid_layer == 1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var path_obj = findObjs({_type: "path", _id: args[2]})[0]; &nbsp; &nbsp; &nbsp; if (path_obj)&nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path_obj.set("layer", new_layer); &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('Move Lighting Script', '/w gm No path object found with that ID.'); &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('Move Lighting Script', '/w gm Invalid Layer Specified.'); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showHelp(); &nbsp; &nbsp; } break; } &nbsp; } }, checkInstall = function() { &nbsp; &nbsp; var script_version = "0.1.4"; &nbsp; &nbsp; &nbsp; &nbsp; if( ! state.moveLighting ) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state.moveLighting = { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version: script_version, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (state.moveLighting.version != script_version) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state.moveLighting.version = script_version; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log("-=&gt; Move Lighting Script v"+state.moveLighting.version+" Initialized &lt;=-") }, &nbsp; &nbsp; registerEventHandlers = function() { on('chat:message', handleInput); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on("ready", function() { &nbsp; &nbsp; 'use strict'; &nbsp; &nbsp;&nbsp; moveLighting.CheckInstall(); moveLighting.RegisterEventHandlers();&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; }); Now I just do the fllowing: 1) Get the ID of the dynamic lighting polygon object blocking your doors line of sight 2) Put the door on the token layer and set the bar1 value to the ID you just got for the dynamic lighting object 3) Create these 2 macros: Open-Door: !movelight gmlayer @{selected|bar1} !token-mod --set layer|gmlayer --ids @{selected|token_id} Close-Door: !movelight walls @{selected|bar1} !token-mod --set layer|objects --ids @{selected|token_id} Add the two macros to your macro bar then after setting all the bar1 values of your doors to the dynamic lighting polygon object blocking line of sight just select the door on the token layer and click "Open-Door" to open it. Switch to gmlayer and select door and click "Close-Door" to close it. That's all there is to it! I couldn't do it with TokenMod alone so I hacked together a workaround. Now I have 1-click opening/closing doors with dynamic lighting / line of sight.
1525146029
GiGs
Pro
Sheet Author
API Scripter
Orrrr you could use the script I linked earlier, which was designed for exactly this, hehe. With that script, you dont need to identify the item's id. Still, the more approaches we have, the better! I've made my own version of scripts other people have already made, too, so i understand the appeal.
G G said: Orrrr you could use the script I linked earlier, which was designed for exactly this, hehe. With that script, you dont need to identify the item's id. Still, the more approaches we have, the better! I've made my own version of scripts other people have already made, too, so i understand the appeal. The other script you linked looked like it had a bunch of other functions I wasn't interested in which is why I opted to just make something simple for a single purpose. And speaking of writing scripts other people have already made I seem to be doing that a lot lately (Patrolling NPCs, Changing Rotation based on movement, etc etc)
1525146352
The Aaron
Pro
API Scripter
One of the best ways to learn something new is just to dive right in. You’ve been doing great at that, keep it up!
1525146488
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I use&nbsp; SimpleDoorControls , a nice script by Three of Swords, and The Aaron. It is similar to what you have written, but even simpler in that you don't need to change layers yourself in order to toggle the doors. You have a control token for each door. I use an invisible png token, with a red GM-only aura set over the door. I have a macro that changes the color to green as it opens the door, and back to red when it closes it. Just so I can quickly see the state of any door on the map. I tried Matt's Door Script for a while, but I liked this because I didn't need all the extras the other script came with, like automatic traps and so forth.
1525146683
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ha! I was sniped by several posts. Curse my slow typing. Sorry, Kastion. Once you've hung around a while, you sort of accumulate scripts, even if you don't wind up using them. I'm totally envious of your ability to write them. I have built a huge cargo cult of macros based on these shiny metal javascript birds.
keithcurtis said: I use&nbsp; SimpleDoorControls , a nice script by Three of Swords, and The Aaron. It is similar to what you have written, but even simpler in that you don't need to change layers yourself in order to toggle the doors. You have a control token for each door. I use an invisible png token, with a red GM-only aura set over the door. I have a macro that changes the color to green as it opens the door, and back to red when it closes it. Just so I can quickly see the state of any door on the map. I tried Matt's Door Script for a while, but I liked this because I didn't need all the extras the other script came with, like automatic traps and so forth. This sounds super neat! I may check it out in the future. Although I did just configure about 40 doors in a 100x100 first floor of a major dungeon I've been working on so I probably won't be switching over to any other door scripts until the dungeon is complete and I have some spare time to tinker. One of the good things that has come out of this is it has forced me to learn and start using the advanced keyboard shortcuts. Makes a load of difference being able to switch between layers with a keystroke as opposed to doing it with the mouse that's for sure!
Great thread! I'm going to play with the script for SimpleDoorControls when I get off work.