
Here's the latest script I've been working on: a script to synchronize changes to a token to all other tokens that represent the same character. Now you can set the tokens representing your PCs to always have the same status markers, for example. Just tell TokenSync which property (or properties) to synchronize, and any time that property changes on any token that represents that character changes, TokenSync will propagate that change to all other tokens that represent that character.
Usage:
API scripts:
Because API scripts making changes to a token doesn't result in change events, TokenSync won't automatically synchronize any token changes caused by an API script. To get around this, there are two options.
Usage:
!tokensync --add property[|properties]
Adds the specified property to the list of properties that TokenSync will synchronize for the character the selected token represents; if you want to specify multiple properties, just separate them with a vertical bar ("|").
!tokensync --remove property[|properties]
Removes the specified property from the list of properties that TokenSync
will synchronize for the character the selected token represents; if you
want to specify multiple properties, just separate them with a vertical
bar ("|").
!tokensync --removeall
Removes all properties for the selected character from the sync list.
!tokensync --forcesync
Forces a synchronizes event to update all properties to match selected token; useful for forcing updates after calling an API script to change token properties.
Properties that can be syncrhonized:imgsrc, bar1_link, bar2_link, bar3_link, width, height, rotation, layer, isdrawing, flipv, fliph, name, aura1_radius, aura2_radius, aura1_color, aura2_color, aura1_square, aura2_square, tint_color, statusmarkers, showname, showplayers_name, showplayers_bar1, showplayers_bar2, showplayers_bar3, showplayers_aura1, showplayers_aura2, light_radius, light_dimradius, light_otherplayers, light_hassight, light_angle, light_losangle, light_multiplier
Note: imgsrc will only sync if the token was created from your library; basically, if ChangeTokenImage.js can change the image, TokenSync can synchronize the change.API scripts:
Because API scripts making changes to a token doesn't result in change events, TokenSync won't automatically synchronize any token changes caused by an API script. To get around this, there are two options.
- Manually force a sync event by calling "!tokensync --forcesync".
- Update the API script to call an update ("tok" is token object with the updated properties, "property" is the property to synchronize; you can synchronize multiple properties by separating them with vertical bars):
if (!_.isUndefined(TokenSync)) TokenSync.syncProperty(tok, property);
Since this checks to see if TokenSync is defined, it's safe to call this in other scripts, even if the user isn't using TokenSync.