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

Questions on Token Sync

1524849145
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
This is the script cooked up by James W, with input from The Aaron. I remember using this at one time, but might have culled it back when I was trying to prune as much as possible to help performance. Before re-installing, I have a few questions that hopefully one or the other of the above coders might answer: 1) Is there any non-negligible process impact on syncing the tokens? 2) Does it sync ALL tokens, or just PCs (i.e. representing characters controlled by players)? 3) Do changes propagate to a token newly pulled from the journal tab, or do you have to force a sync to bring it up to date. 4) Does token mod make an update call to this, or would I need to add the two lines of code recommended in the script? This would require me switching to a manual install of token mod instead of the one click, but I can live with that. Also, would the two lines simply be appended to the end of token-mod (and any other script that makes an API-instigated token change)? 5) Question for anybody: Any caveats to using this?
1524850095

Edited 1524850678
The Aaron
Pro
API Scripter
Latest version seems to be here:&nbsp; <a href="https://gist.github.com/SCPRedMage/c9c0187a0f75f6b" rel="nofollow">https://gist.github.com/SCPRedMage/c9c0187a0f75f6b</a>... 1) It's using filterObjs() which is not taking advantage of indexing that Riley added, I'd suggest updating it to do a findObjs() for tokens and then filter the results which should be much faster.&nbsp; It only runs on a few events: "add:token", "destroy:character", and "change:token:represents", so shouldn't have large impact to general gameplay. EDIT : Oh... just noticed it dynamically registers listeners on properties it monitors, so those would get adjusted on every change to a token, and would need to be enhanced to be called by TokenMod as well.&nbsp; The way it's done now, it would handle each property individually. Probably better to register to a general change, then check if any of the properties it cares about were changed and update then.&nbsp; Less overhead.&nbsp; That's what I'd probably do if you wanted to use this. 2) It syncs any token that represents a character, regardless of who does or does not control it. 3) Pulled in tokens will trigger "add:token" and get updated... probably.&nbsp; &nbsp;The event model has gone through some unfortunate changes in the last few years that have lead to a bit of nondeterminism when dealing with "add:token" events. I've had to make several changes in TokenNameNumber to account for them.&nbsp; Probably this should be updated with similar changes which defer changing a token for some fraction of a second to allow the current settings to stabilize before making additional changes which would be overwritten. 4) I'd do it the other way around and add subscription to TokenMod changes into this script.&nbsp; Much cleaner and you're already manually using this script. =D&nbsp; BTW, did you know you can use a character_id as an argument to --ids on TokenMod to have the change propagated to all tokens representing that character automatically?&nbsp; =D 5) nothing else I can think of besides the above... =D
1524850687
The Aaron
Pro
API Scripter
(edit above)
1524852715
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
1) Oof. Sounds more trouble than the minor convenience I would enjoy. 3) as above 4) I did not know that. Would it also update if the value I was setting it to was just a call to the existing value? I.e. a call to set bar 1 to value of bar 1, in order to catch manual changes? What prompted me to consider re-installing was that, when switching to a new map, I'd like to be able to pull fresh tokens, rather than copy/paste, since the resulting tokens might get placed behind a dynamic lighting wall. If the token has some recorded damage, currently, this would not be reflected. It would pull a fresh, healthy token.
1524853016
The Aaron
Pro
API Scripter
For players with the HP tied to an attribute, they should be up to date already by virtue of the link. ? Or do you track damage in other ways?&nbsp; Or am I missing the point of what you're saying?&nbsp; =D
1524853559
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Never mind. :) I just discovered that my default token setting macro has been setting up PCs as mooks. Apparently this has been going on so long I have forgotten and gotten used to the workaround. Derp. I'm going back to work...
1524853701
The Aaron
Pro
API Scripter
=D
1524855376
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I think it started with the latest design of the shaped sheet. The Max HP is such a tiny field, the players were just filling in the great big "current" field and leaving the max at 0. This was throwing things off, to say the least. Fixing them with chatsetattr.
1524856755
The Aaron
Pro
API Scripter
Yeah, we've hit that as a user issue lately too.&nbsp;
1524877244
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thank goodness it's not just me.