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

Can you use an API to mirror movement of a token on a different page?

I have two duplicate pages A & B.   Can I set up a token that is moved on page A to be moved to the same X/Y location on page B?
1589430340
The Aaron
Roll20 Production Team
API Scripter
Yup, that's what the Twins script does:&nbsp;<a href="https://app.roll20.net/forum/permalink/1634979/" rel="nofollow">https://app.roll20.net/forum/permalink/1634979/</a>
1589433698
Gold
Forum Champion
This seems radical cool. Thinking of ideas.. Would love to hear your implementation / purposes / game methods for "Twins"?
1589457994

Edited 1589459882
Can you modify the Twins script to ignore layer? (Just read the text, you can select whatever attributes you want to track) &nbsp;This will make double blind play possible. Page A’s side B figures will be on the GM layer. &nbsp;While Page B’s Side A figures will be on the GM Layer. &nbsp;As figures are spotted they are pushed to the Token layer! &nbsp;Hidden Movement here we come!
1589458252
The Aaron
Roll20 Production Team
API Scripter
If your remove 'layer' from the props array on line 13, it won't mirror the layer property.
1589459966

Edited 1589460434
Argh! &nbsp; X/Y axis is all I want. &nbsp;I’m not Pro level yet, so I can’t look at the code. &nbsp;Wonder if you can transpose layers in the script?
1589461209
The Aaron
Roll20 Production Team
API Scripter
It would be possible.
1589461249
The Aaron
Roll20 Production Team
API Scripter
You can view the code here: <a href="https://github.com/shdwjk/Roll20API/blob/master/Twins/Twins.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Twins/Twins.js</a>
Twins works reflectively? &nbsp;Meaning moving either will affect the other? &nbsp;I’m not terribly experienced with JS. &nbsp;If the script knows the active token (the one the player is moving) and layer != layer then set both to GM within script, correct values, return to initial values. &nbsp; Not sure if that would work as I need to see how the twin fires. &nbsp;Does it move dynamically or after the token stops?
1589480338
The Aaron
Roll20 Production Team
API Scripter
The API acts based on events.&nbsp; In the case where a token is moved by a human, the API will get an event that has the previous properties of the token and the new properties of the token (where left and top have been changed).&nbsp; Twins takes the list of properties that is sent, and the list of properties that it duplicates.&nbsp; For each changed property, it makes the same change on the linked token.&nbsp; If token A in an A-B pair is changed, token B is updated.&nbsp; If token B is changed, token A is updated.
Thank you! &nbsp;Do you think setting and restoring layer would work?
1589548472
The Aaron
Roll20 Production Team
API Scripter
I'm not completely sure what you mean by that.&nbsp; If they are mirroring the layers, they will certainly both be on the same layer.
1589555765

Edited 1589555870
The idea is, if the layers are not equal store the layers values, then move both to the GM layer, move the token, then restore the original layers.&nbsp; The twin's are not linked by layer. Example" Page A's tracked token is on GM layer, and Page B's the tracked token is on the Token layer.&nbsp; When the token is moved it compares, the two token's layers, if not identical, it stores the layer values for both tokens, then moves them both to GM layer, moves them, then restores the original layer. So in setting up,&nbsp; I have both tokens unified on Token Layer.&nbsp; On Page A, I move the token to the GM layer, the code runs and tracks the change layer.&nbsp; So now the tokens are unified in all but layer.&nbsp; I move the token.&nbsp; The layers don't match, so the code, stores each token's layer, moves them both to GM layer (to unify them) moves the twin token, then restores the original layers.&nbsp; Is this a valid approach?