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

TokenNameNumber

Ok, I admit, I am being very lazy here. I am using some of the WOTC published adventures along side the shaped script and character sheet. I make a lot of use of the Token Name Nuber script, but when i set up the tokens already on the maps to also use the %%NUMBERED%% syntax, I then have to re-add the tokens to the page or they just show the name with %%NUMBERED%% on the end eg Thorn Slinger %%NUMBERED%%: Is there a way to update all these tokens without having to re-add them to the map? Thanks in advance
1502744927
The Aaron
Pro
API Scripter
hmm....  Try this on a copy of the game and see if it does what you want? on('ready',function(){ "use strict"; _.chain(findObjs({type:'graphic'})) .map((o)=>{ return { token:o, character:getObj('character',o.get('represents')) }; }) .reject((o)=>_.isUndefined(o.character)) .reject((o)=>o.character.get('controlledby').length) .reduce((m,o)=>{ let pageid=o.token.get('pageid'); m[pageid]=m[pageid]||{}; m[pageid][o.character.id]=m[pageid][o.character.id]||[]; m[pageid][o.character.id].push(o); return m; },{}) .each((cs,pageid)=>{ _.each(cs,(cos,cid)=>{ let n=0; _.each(cos,(o)=>{ o.token.set({ name: o.character.get('name').replace(/%%NUMBERED%%/,++n) }); }); }); }); });
1502744981
The Aaron
Pro
API Scripter
If it doesn't, I'll see about adding a command to TokenNameNumber to search for tokens with the %%NUMBERED%% in the name that haven't been renumbered.
Thank you, As i say, jsut me be very lazy.
1502745408
The Aaron
Pro
API Scripter
The other thing you could try is selecting all of them and hitting ctrl-x ctrl-v to delete and recreate them.  That should trigger TokenNameNumber to rename them.
1502745555

Edited 1502745763
i didnt think of that, that code i am afraid did not work, i added it as a new script? sadly there is no cut, only copy, and pasting then gives a massive off-set
1502745770
The Aaron
Pro
API Scripter
yeah. bummer.  try the Cut/Paste route?
no cut only copy sadly
1502746237
The Aaron
Pro
API Scripter
ok, I'll see about adding that as a command to TNN.
Thanks Aaron. Really do appreciate it. 
For anyone else trying, i have found copying and pasting works, deleting the originals and moving the group back en-masse works
1503679719
The Aaron
Pro
API Scripter
Great!  I'll still see about a command, but GenCon has slowed me down =D
I'm not jealous at all of that!!