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] Portal — Convert old Dynamic Lighting to Modern Doors and Windows, Including bulk Door and Window control

1764751724

Edited 1764751895
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Portal This script manages doors and windows (“portals”), allowing you to: Create portals on the map Lock / unlock them Toggle open/closed state Shutter / unshutter windows Hide / unhide doors Convert Doors and Windows from paths or pathv2 objects Bulk-select and modify portal Properties [ Video Demo ] Base Command: !portal This will bring up a control panel in chat. The script can be almost entirely operated through this interface, but the commands and action of the script are detailed below. Conversion Commands --convertwindow — Convert selected doors or paths into windows. --convertdoor — Convert selected windows or paths into doors. --convertall — Apply the same conversion to all similar objects: Doors → all doors of same color Windows → all windows of same color Paths → all paths matching color and barrierType Attribute Commands Format: --attributeName|value Values are case-insensitive. Booleans accept: true: true, yes, on false: false, no, off flip: toggles true/false Common Door/Window Attributes --isLocked|true/false/flip --isOpen|true/false/flip --isSecret|true/false/flip --isShuttered|true/false/flip --color|#rrggbb --color|default — sets selected doors or windows to Roll20 defaults Position Attributes Use + or − prefixes for relative moves: --x|100 — set position --x|+20 — move right 20 units --x|-20 — move left 20 units --y|100 — set position --y|+10 — move down 10 units Note: All Y and Y values are figured with the top left corned of the map being (0,0), and positive values increasing toward the lower right, to conform with how graphics are handled. Path Handling Only paths with exactly two endpoints are converted. Paths with more points are skipped and noted in chat. Position is taken from the path endpoints. General Rules All commands are case-insensitive. All provided attributes apply to every selected object. Missing attributes (e.g., isSecret on windows) are ignored. Examples !portal --convertwindow !portal --isLocked|true !portal --isLocked|flip --isOpen|false !portal --x|+20 --y|-10 !portal --convertwindow --color|#FF00FF --isLocked|true
Hey Keith, this looks awesome! Video is very helpful (I didn't know what was meant by 'paths' although I sort of guessed).
1764782163
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks, Doug! You guessed correctly. "Paths" refers to objects drawn with the various drawing tools. That is their object type in the API, like, graphic, journal, or page. When the new engine came out to replace the legacy engine, the devs created a new object type: pathv2, which uses a different coordinate system, (I have no idea why this was done). The script can handle either. So paths = lines.
This seems like it will be very useful to quickly convert older purchased Roll20 modules to use the new doors feature. Thank you for sharing!
1764866986

Edited 1764867048
Hi Keith, this looks very handy, especially for conversion of older stuff. I have been using ScriptCards to assign lock pick DC and break DCs to my doors and windows. It works but is a bit clunky (it uses part of the hex code to set those). If you don't ask, you don't get...is there any way this could be used to set DCs for doors/windows? 
1764870617
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Simon! Sure thing. You can set the hex code with a Portal macro, like: !portal --color|?{Set DC for Lock|DC8,#123456|DC11,#AA11EE|DC15,#22EE44|No DC|default} And adjust for your DCs and Colors. You could even make it a two parter: !portal --isLocked|?{Is the Door Locked|Locked,true|Unlocked,false} !portal --color|?{Set DC for Lock|DC8,#123456|DC11,#AA11EE|DC15,#22EE44|No DC|default} And set the "Locked" and color values in the same macro.
Hi Keith, sorry for delay, I just hadn't had chance to test it.  Love the interface and actually it does everything I need without going for chat commands via Custom Colour. On a one off basis although it doesn't really save me any time since I can set the door colour using the drop down on the door itself,  I have to say I prefer your UI for setting it, so will use it anyway.  Where it really scores is the ability to update all selected, now I can set every door to default and then amend individuals as needed... peachy.  Another belting utility from you Keith, thank you