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] CommandDoors - Use CommandTokens to toggle open/closed states for doors, including wall modification for dynamic lighting.

1381283553

Edited 1381284072
<a href="https://gist.github.com/goblinHordes/6894547" rel="nofollow">https://gist.github.com/goblinHordes/6894547</a> CommandDoors Use CommandTokens to toggle open/closed states for doors, including wall modification for dynamic lighting. Requires: CommandTokens.js Once configured, doors are easy to use - simply move the associated CommandToken to toggle the door from open to closed and back again. Configuring the doors takes a bit of work, but there is a helper function to make the process pretty easy. Before configuring a door, first look at the components of a CommandDoor. A CommandDoor consists of three tokens and an optional Polyline. The first token is a CommandToken that will be used to trigger the door toggle. The other two tokens are the openDoor and closedDoor graphics for the door, and should be the same size as each other. The optional Polyline path is used for blocking on the dynamic lighting layer. Toggling the door via the ControlToken will cause the active door graphic to be shrunk, the new door graphic to be enlarged to its native size, and the path to be switched beween 'wall' and 'gmlayers' depending if the door is closing or opening, respectively. The name of each of these tokens is very important. The CommandToken is configured to call the toggleDoor function with two parameters, the door group ID and, optionally, the path ID. This follows the standard CommandToken naming convention, please see CommandTokens.js for more details. The door images need to be named _door_open_ X _ and _door_closed_ X _ where X is a unique ID for that door group. Finally, the path doesn't need any special naming, but its ID is used in the CommandToken. Here is an example of a complete door set by name/id: openDoor: _door_open_01_ closedDoor: _door_closed_01_ path (id): -J5Glj9y-cipFNgrV141 CommandToken: __toggleDoor_:01:-J5Glj9y-cipFNgrV141__ Included in this script is a helper function for linking door sets. To use this script in quickly planning maps, I maintain a page in my campaign with template sets. This way I am able to quickly copy and paste the templates then link them into a new set. This makes door creation take only a few seconds. In order to link a door group you must start with the three required tokens, but named in a specific way: openDoor: _door_open_ closedDoor: _door_closed_ CommandToken: __toggleDoor_ With those three tokens selected, use the !linkDoors API chat command to update their names and link them into a new door set. You'll have to link the path manually, this is on purpose since the wall layer doesn't understand rotation. By default, !linkDoors will search for the next incremental integer ID from the existing _door_open_ X _ objects. You can also pass an ID that you'd like to use. In macro form this can be very useful to prompt for an ID: !linkDoors ?{Door ID}
Here is a video of the CommandDoor in action: <a href="https://vimeo.com/76493596" rel="nofollow">https://vimeo.com/76493596</a> And another of using the !linkDoors command: <a href="https://vimeo.com/76493597" rel="nofollow">https://vimeo.com/76493597</a>
ok, late in coming, but this is just such an awesome addition to ANY game - I can't see why people wouldn't use it if they had the means to do so. Keep up the good work!
This is just my first pass at it, first serious R20API script at all. I'm already most of the way through a rewrite of the CommandTokens using proper namespacing and not relying on the name of a token. Once that is complete, I'll redo CommandDoors with the ability to have multiple paths associated with a door (openedPath, closedPath) and have them do color switching to work with the existing collision detecting scripts on this forum.