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]Door Knocker

1566157462

Edited 1604868913
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Folks, I've been looking for a better way to handle dynamic lighting lines for doors lately, and I think I've created an easy to use and set up solution. There are already some great solutions out there, but I wanted something that could be as close to "load and go" as possible. With this in mind, I created Door Knocker. It's a door management script that doesn't need any pre placement of door controls or linking of DL lines to door control tokens. Simply drop the door knocker character onto the map, make sure all your doors are a single color, and set that as the color of doors in the script's settings; and you're good to go. You can find the code in two places: Stable Released Code: in the Roll20 API repository or get it from the on-click drop down Beta In Development Code: No Beta version currently Full details on how to use the script are below. Hope you all like it, Scott EDIT: And, cause I'm a thankless task master, I forgot to thank Keith for his assistance in alpha testing this script and designing the scope of the script, and The Aaron for his help in figuring out some of the calculation issues. :End Edit EDIT the 2nd: The script has two dependencies: Path Math and Vector Math by Stephen L. Both of them are available from the one-click drop library. Door Knocker v1.12 Welcome to Door Knocker. This script helps quickly open and close doors by controlling the dynamic lighting lines. If you have any questions, comments, or find a bug; please drop by the&nbsp; Door Knocker forum thread . Using Door Knocker The script will move dynamic lighting lines used as doors to the map layer and make them transparent, opening the door. It determines what is a door and a wall based on the stroke color of the polygon and will only open doors within 1 square (default 70px) of the door knocker token. Basic Command Syntax The script uses a standardized API command syntax. All Door Knocker commands will begin with&nbsp;!knock. This will then be followed by a space a double dash preceding a keyword and options group. This looks like this: !knock --keyWord|option1|option2|... Opening and Closing Doors Open and close using the&nbsp;key&nbsp;or&nbsp;push&nbsp;keyword followed by an option to tell the script whether to open doors, close doors, or toggle doors. You can also pass an optional second option to tell the script to open/close/toggle all doors within range of the knocker token, on the page, or in the campaign. These commands look like: !knock --key/push|open/close/toggle|all/page/campaign key/push: &nbsp; This is the keyword that tells the script to manipulate door dynamic lighting lines. The&nbsp;key&nbsp;keyword operates on both locked and unlocked doors and is GM only. The&nbsp;push&nbsp;keyword only operates on unlocked doors. open/close/toggle/reveal/hide/togglehide/anyopen/anyclose/anytoggle: &nbsp; This option tells the script to open, close, or toggle (open closed doors and close open doors) the closest door (or all doors if also using the all option described below). Reveal, hide, and togglehide cause the command to work on hidden doors instead and only work with the&nbsp;key&nbsp;keyword. anyopen, anyclose, and anytoggle work on all types of doors and only work with the&nbsp;key&nbsp;keyword. all/page/campaign: &nbsp; Optional argument &nbsp;This option tells the script to operate on all doors within range, all doors on a page, or all doors in the campaign. The&nbsp;page&nbsp;and&nbsp;campaign&nbsp;keywords are GM only and do not work with the&nbsp;push&nbsp;keyword. Setting up the Door Knocker Set the wall, door, and locked door stroke colors in the settings menu using hex color codes (e.g. #000000). You can also set these values by selecting an already created DL line. This functionality is only accessible to the GM. The command syntax for using a selected DL line looks like: !knock --preset|wall/door/unlocked/hidden/farAura/closeAura|hex color preset: &nbsp; This is the keyword that tells the script to change it's settings wall/door/unlocked/farAura/closeAura: &nbsp; This option tells the script to update the color setting for walls, doors, unlocked doors, and close and far door detection hex color: &nbsp; Optional argument &nbsp;Passing a hex color here will set the script to consider all polygons on the Dynamic Lighting layer with a stroke of this color to be doors/walls. If this option is not passed the script will look for a selected polygon to pull a stroke color from. Setting up your maps The only map setup needed is to ensure your dynamic lighting doors are the appropriate color. This functionality is only accessible to the GM. If you are adapting a module or add-on to an already existing door color scheme you can select a door line and run the following chat command: !knock --adapt|door/wall/unlocked/hidden|campaign adapt: &nbsp; This is the keyword that tells the script to update all polygons on the dynamic lighting layer with the same stroke color as the selected polygon(s) to have the script's door/wall stroke color wall/door/unlocked: &nbsp; This option tells the script to update the stroke color to that of walls, doors, or unlocked doors campaign: &nbsp; Optional argument &nbsp;adding this optional argument tells the script to update polygons on all pages, not just the current page. Searching for Doors By default the script will create two auras around the door knocker token when a door is with in range. Aura 1 will display the range to the closest door while aura 2 will display the range to the furthest door. You can customize what color these auras are from the settings menu on this character. You can also turn the feature can off (or back on) from there as well. It is also possible to generate these auras on other tokens by selecting them and running the following command: !knock --search|on/off search: &nbsp; This is the keyword that tells the script turn on or off aura detection of nearby walls for the selected token(s) on/off: &nbsp; Optional argument &nbsp;Adding this optional argument will tell the script to only turn on or off aura detection. When omitted the script will toggle aura detection instead. Using this feature will still allow you to use your token's auras as you wish because the aura is actually created on an invisible token that is slaved to the selected token. Customizing the Script Door knocker token The script uses a generic key token as the door knocker token. You can customize this by changing the default token of this character. Script created abilities The script also creates six abilities on this character as token actions. These can be disabled as token actions, but should not be deleted as the script will simply remake them. You can also add whatever other macros you want to this character. Attributions The default token image is from&nbsp; <a href="https://game-icons.net/" rel="nofollow">https://game-icons.net/</a> &nbsp;under the&nbsp; creative commons license . Thanks to Keith Curtis for finding this awesome token. For those that prefer visual and auditory learning. There's now a tutorial video . Known Issues (as of 9/3/19) The search function will not currently work with maps using an actual map image as the aura is displayed behind all the images on the map layer. EDITS 11/8/20 Removed the broken demo gif. Added a link to a tutorial video 9/3/19 Updated the how to in the post to reflect the current version (1.12) Added a Known Issues section
1566157926
vÍnce
Pro
Sheet Author
Looks like I just found a new door handling script.&nbsp; Thanks Scott
1566157971
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I have playtested this, and it is the best door solution I have yet seen. You can prep a whole module in like, 10 seconds. Literally. Kudos to Scott. This will be in every game I run.
1566158677
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Thanks guys. I had forgotten to thank Keith and Aaron for their help on the script. That's now in the OP, along with a gif of the script in action.
1566160847
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Mostly, I feel like Aladdin, here. Thanks Genie!
1566171329
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Minor update pushed. Added a safety interlock to prevent improper hex colors from being accepted by the script. Also fixed several typos and grammatical errors.
1566172682
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Which is a fancy way of saying that Keith can find creative ways to wreck things... :D
Can't wait to try this!
Wow, can't wait to try this!
1566224297
Pantoufle
Pro
Sheet Author
Translator
Wow this is super cool and easy to use! Question : is it possible for a player to use the token? If so, is it possible to create a 3rd color for gm only doors (perhaps with a gm token so that the secret doors remain secrets with aura) ?&nbsp;
1566225332
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Can't speak for Scott, really, and can't test at the moment because games are down, but you should be able to edit the permissions on the Doorknocker UI character. Then only you can move or edit it.
1566225435

Edited 1566225631
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Pantoufle said: Wow this is super cool and easy to use! Question : is it possible for a player to use the token? If so, is it possible to create a 3rd color for gm only doors (perhaps with a gm token so that the secret doors remain secrets with aura) ?&nbsp; This is a stretch goal for the script. Currently the script is GM only, but one of the goals that Keith and I came up with was some sort of handling for locked/hidden doors. I wanted to get this out in its current state though as I'm about to get very busy prepping for graduation and wasn't sure when I'd have a chance to add that functionality. So, the TL;DR is, eventually I'd like to, just not sure when it will happen. EDIT: keithcurtis &nbsp;said: Can't speak for Scott, really, and can't test at the moment because games are down, but you should be able to edit the permissions on the Doorknocker UI character. Then only you can move or edit it. Currently the script has an extremely narrow scope. The DoorKnocker UI character is created as a GM only character, and currently even if you give players access to the character, the script won't react to any non GM commands sent (other than the aura creation on a token move).
1566226078
Pantoufle
Pro
Sheet Author
Translator
Ok! That is already a swift and useful tool! Can't wait for an enhanced version :D
I have tried this in 2 games at this time. Set up was smooth....:) But both games sandbox's crash when I move token next to door... For reference, the error message generated was:&nbsp; Error: Firebase.update failed: First argument contains Infinity in property 'aura1_radius' Error: Firebase.update failed: First argument contains Infinity in property 'aura1_radius' at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186) at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207) at Aa (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462) at Ea (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403) at J.update (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318) at TrackedObj._doSave (/home/node/d20-api-server/api.js:850:27) at later (/home/node/d20-api-server/node_modules/underscore/underscore.js:892:31) at Timeout._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:829:19) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5)
1566226640

Edited 1566226730
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad set up went well BilBo, sorry about the bug though. I haven't run into that previously. I'll try to find some time to get that figured out today. Can you post a screencap of your token in relation to the DL lines in question? Pantoufle &nbsp;said: Ok! That is already a swift and useful tool! Can't wait for an enhanced version :D glad you like it, and I'm looking forward to it too.
Each square is 10' I did not slowly increment it to door line, to see at what point it fails though. Currently it is about 4.9'
1566227348

Edited 1566227451
Slowly creeping to door... right around the 9-10' range it faults. Probably right around when the Aura's wants to turn on.
1566227983

Edited 1566584477
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, thanks for that BilBo. I'm not entirely sure why it's doing that, but I've just made a potential fix. Could you try with the 1.01 code found in my fork of the repo ?
Just installed and tried the script out. It's fantastic! I love how easy it is to set up, and how it's not keyed to particular doors, so once you've defined your door color and your wall color, all you're doing is bringing the token within range of the door and hitting one macro button. Question: the documentation references the ability to set locked-door color as well as regular-door color, but I can't seem to figure out how to set the former. The settings panel only gives me two color options, one for doors, and one for walls. Nothing for locked doors. Am I missing something?
1566231103
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Woops, that was a bit left over from when I was discussing design goals with Keith. It's a feature that I want to add later, but unfortunately is not yet implemented.
Scott C. said: Woops, that was a bit left over from when I was discussing design goals with Keith. It's a feature that I want to add later, but unfortunately is not yet implemented. OK, good to know I wasn't missing something super-obvious, which is what normally happens with me! :) I'd love to see that feature added later, for what it's worth. But this is such an amazing, simple script as is. Thank you!
Same thing... For reference, the error message generated was:&nbsp; Error: Firebase.update failed: First argument contains Infinity in property 'aura1_radius' Error: Firebase.update failed: First argument contains Infinity in property 'aura1_radius' at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186) at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207) at Aa (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462) at Ea (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403) at J.update (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318) at TrackedObj._doSave (/home/node/d20-api-server/api.js:850:27) at later (/home/node/d20-api-server/node_modules/underscore/underscore.js:892:31) at Timeout._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:829:19) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5)
1566232205
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmmm, ok that's weird. Can you pm me a game invite Bilbo and gm me when I join? When I get a chance I'll hop in and do some troubleshooting since I can't replicate it on my end.
1566236252

Edited 1566236283
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Thanks to BilBo letting me dig around in his game, found the cause of the error he was having. It was caused by having the grid turned off on the page. Uploaded v1.02 of the script which can now handle gridless maps. (I think this is a record for me, 3 separate versions in one PR)
Thanks -- nice catch I knew about the error, didn't know where that was coming from.. Wasn't causing an issue, never looked into it. Will dig around a bit and see if I can find it.
1566241698

Edited 1566241855
This is great!&nbsp; Now all we need is an API called ShutterLight, that will allow different line colors for Windows to be opened and closed.&nbsp; This will allow light back and forth thru window, but still block the character from proceeding through it when DL restricts characters' movement...&nbsp; The way it is now, I could have lemmings jumping from castle towers bc .... well .... they can .... even through stained glass .... Otherwise, I can't let the sun shine in.&nbsp; Poor Lemmings.&nbsp; Always in the Dark.
1566252691

Edited 1566253503
Love it. - Can I ask... is it possible to make each of the characters 'the key'. Meaning that the player can simply walk up to a do and 'open it' without needing to move the key token next to it? Also, is it possible for the players to enact the script here? or does it need to be the DM? EDIT: On some testing, it looks like players can use this feature,
1566253331
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Godthedj, see the discussion a few posts up. This funcionality is coming, but the current iteration of the script isn't designed for it. As for players having access, they shouldn't. The script is programmed to not accept non gm messages or messages with a non DoorKnocker token (a token that does not represent the Door Knocker character) selected.
Scott, thanks - I tried 'switching to player' and it still worked for me, but maybe the script is smart enough to know that I'm still the DM (in disguise!) - Thanks for your work!
1566255205
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, interesting, I wonder if the Roll20 provided gm checker doesn't account for that.
1566364503

Edited 1566585211
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi folks, Had some issues with the PR to get the code on one-click this week. Hopefully it will be up next week. In the mean time, I've found some time to work on the next version of the script. I've got some code that's ready for some beta testers if anyone is interested. You can find V1.10 (BETA) of Door Knocker in this fork of the repo . Door Knocker v1.10 (BETA) New Features Support for player vs. gm only accessible doors Open/close commands can now be run on a non door knocker token. Script controlled aura colors Aura detection of doors can now be done on non door knocker tokens. (creates a shadow token on the map layer to follow the master token around) Stricter testing of entered hex colors to ensure they work Full Details can be found in the new version's help document on the character.
I'm just posting to say thank you for this awesome script.&nbsp; No longer do I dread walking my players through a dungeon and having to painstakingly move lines on the dynamic lighting layer. Seriously, thank you!
Awesome scott. I'll do some Beta Testing!
This is GREAT! Awesome job!
1566577408

Edited 1566577657
Having an issue getting the all doors to open/close using the page or campaign option. Anyone have a working macro they can post? Also: is there anyway to make the script move the lines to the GM layer instead of making them disappear this way the GM knows whats open and closed? I ran the script for the first time last night in session and I ran into an issue of not knowing what doors where open and what were closed I had to keep going to DL Layer to see if the lines where there or not.
1566579984

Edited 1566587145
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, the following macro should work: !knock --key|open|page Change the open for close and page for campaign if needed. If that isn't working, are you getting an error sent to chat? Or is the API crashing? EDIT: Also, note that the page and campaign options are only available with the key &nbsp;keyword, not the push &nbsp;keyword. For the feature request: I'll think on it. Sending the polygon to the map layer and making it transparent was a deliberate choice on my part to avoid cluttering up the gm layer and not have to worry about whether someone made a line on the gm layer in a door's color that isn't actually a door.
1566587071
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
New Beta Version Door Knocker v1.11 (BETA) New Features Features from v1.10 still to be tested Support for player vs. gm only accessible doors Open/close commands can now be run on a non door knocker token. Script controlled aura colors Aura detection of doors can now be done on non door knocker tokens. (creates a shadow token on the map layer to follow the master token around) Stricter testing of entered hex colors to ensure they work New Features in v1.11 Support for hidden doors Commands to control visible doors, hidden doors, or any type of door Full Details can be found in the new version's help document on the character. Code can be found in this branch of my fork of the repo .
Scott C. said: Hmm, the following macro should work: !knock --key|open|page Change the open for close and page for campaign if needed. If that isn't working, are you getting an error sent to chat? Or is the API crashing? For the feature request: I'll think on it. Sending the polygon to the map layer and making it transparent was a deliberate choice on my part to avoid cluttering up the gm layer and not have to worry about whether someone made a line on the gm layer in a door's color that isn't actually a door. Okay thank you I appreciate it, the macro didn't seem to work on my end though. And I can understand that, thanks for considering.
Scott C. said: New Beta Version Door Knocker v1.11 (BETA) New Features Features from v1.10 still to be tested Support for player vs. gm only accessible doors Open/close commands can now be run on a non door knocker token. Script controlled aura colors Aura detection of doors can now be done on non door knocker tokens. (creates a shadow token on the map layer to follow the master token around) Stricter testing of entered hex colors to ensure they work New Features in v1.11 Support for hidden doors Commands to control visible doors, hidden doors, or any type of door Full Details can be found in the new version's help document on the character. Code can be found in this branch of my fork of the repo . Wow the player macro function is so clutch! My players are gonna love this!
1566587309
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmm, and no error or api crash? odd. Could you PM me a game invite and I'll try to do some troubleshooting in the game where it's not working.
I'm having trouble using the BETA code. It is treating the 'unlocked doors' the same as the walls, probably due to them both being the same colour. If I 'open' a door, and then click open again, it opens up an entire wall? - Is it something stupid I'm doing wrong? See video here for reference... <a href="https://youtu.be/IpyFlivFeMY" rel="nofollow">https://youtu.be/IpyFlivFeMY</a>
1566590704
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Doors, walls, unlocked doors, and (with the newest beta) hidden doors all have to be a different color as the script differentiates them based on their color.
1566592127

Edited 1566592201
In my game, i don't have any 'locked' doors. Just walls and unlocked doors. But I'm not sure how to change the colour of any of any 'definitions'. I tried going into the keys 'settings' and clicking on the different colours but whatever I write in the box, it doesn't appear to change anything... as per the video linked above.
The toggle option is no longer working for me anyone else?
1566595696

Edited 1566598506
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey folks, some bug fixes here, as well as the features that need testing from 1.10 and 1.11. Door Knocker v1.12 (BETA) New Features Features from v1.10 still to be tested Support for player vs. gm only accessible doors Open/close commands can now be run on a non door knocker token. Script controlled aura colors Aura detection of doors can now be done on non door knocker tokens. (creates a shadow token on the map layer to follow the master token around) Stricter testing of entered hex colors to ensure they work Features from v1.11 still to be tested Support for hidden doors Commands to control visible doors, hidden doors, or any type of door New Features/Bug Fixes in v1.12 Toggle commands were not properly searching for nearby doors Setting polygon colors for door types/walls was erroring Edit: When using the page or campaign options to manipulate a door; you no longer have to have the selected token in range of a door. Full Details can be found in the new version's help document on the character. Code can be found in&nbsp; this branch of my fork of the repo .
Scott C. said: Hey folks, some bug fixes here, as well as the features that need testing from 1.10 and 1.11. Door Knocker v1.12 (BETA) New Features Features from v1.10 still to be tested Support for player vs. gm only accessible doors Open/close commands can now be run on a non door knocker token. Script controlled aura colors Aura detection of doors can now be done on non door knocker tokens. (creates a shadow token on the map layer to follow the master token around) Stricter testing of entered hex colors to ensure they work Features from v1.11 still to be tested Support for hidden doors Commands to control visible doors, hidden doors, or any type of door New Features/Bug Fixes in v1.12 Toggle commands were not properly searching for nearby doors Setting polygon colors for door types/walls was erroring Full Details can be found in the new version's help document on the character. Code can be found in&nbsp; this branch of my fork of the repo . Thank you! Working Great!
1566598607

Edited 1567531024
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Good to hear, also had forgotten one new feature in the latest beta build (it's now included in the list above): When using the page or campaign options to manipulate a door; you no longer have to have the selected token in range of a door. (Thanks to Anthony for pointing the erroneous behavior out)
1567523392

Edited 1567531049
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey all, while discussing Aaron's new script with him ( you should totally check it out ), I discovered that I'd screwed up the search functionality on non door knocker tokens (tokens that don't represent the Door Knocker character). Unfortunately, Auras from tokens are the very bottom of the "stack" on each layer. This means that on any page that uses a map image, the search function is useless on non door knocker tokens. I'm swamped with work at the moment, but I'll get a fix out at some point.
I've been using it and it's been going great , as the DM. It's nice that I can run the code on any token, not just the 'key' token. Since I understand that players can't currently open ANY doors using the script, I have no use for 'locked' doors vs 'normal' doors. The only thing that I think would make this any better would be to give players access to open the doors themselves. I'd combine it with a simple macro button, so it calls out.... /em opens the door.... !knock --key|open Just so if they do open it.... everyone will be notified the door has been opened.
1567528915

Edited 1567531104
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey godthedj, With version 1.1x, players can open unlocked doors with the --push keyword. See the updated help document in game for more details. EDIT: And I just updated the how to in the OP to reflect the current version (v1.12)