Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Script:TokenSync

From Roll20 Wiki

Revision as of 14:14, 17 June 2020 by Andreas J. (Talk | contribs)

Jump to: navigation, search

API Script Author: James W., The Aaron
Version: 1.60
Last Modified: 2016-3-13
Code: TokenSync
Dependencies: None
Conflicts: Unknown

TokenSync is 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.

Contents

Usage

!tokensync -- This is the interface command, with the following options:
Parameter Description
--help Displays the help script.
--add property 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 ("|").
--remove property 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 ("|").
--removeall Removes all properties for the selected character from the sync list.
--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.

Changelog

v1.6 (2016-03-20)

  • More optimizations, courtesy of The Aaron


v1.5 (2016-03-17)

  • Refactored schema to simplify code


v1.1 (2016-03-17)

  • Added syncing new tokens, sync on represents change, remove deleted characters


v1.0 (2016-03-16)

  • Release