Advertisement Create a free account

Script Request if its there, [Arranging tokens to saddle side by side]

So, I know I make a few of these, sometimes someone has already made it. Basically I was wondering if there was a script which reorganises tokens on a page so they fit on the grid next to each other. For example if they are scattered across the page, I want all selected tokens to be moved next to other neatly in say a 3 x 3 grid fashion. Basically clustering them out. I find that moving tokens around a map when they are disorganised to be a bit time consuming. Another request was if someone had a simple token-resizer based on pixels? I know I have seen them about included in other scripts but not as a standalone feature. Sometimes I have larger maps than 5 ft squares and like to shrink the tokens on 10ft grids etc. I would like to speed up the action of shrinking each token manually from the standard 70x70px squares across a range of selected tokens.
1464180886
The Aaron
Forum Champion
API Scripter
You can use TokenMod for the second part: !token-mod --set width|[[70*?{Scale|1}]] height|[[70*?{Scale|1}]] The first is a bit harder.  So, you select N different tokens and want to execute a command that moves them all to be grid aligned and in the tightest square possible?  (2x2, 3x3, 4x4, etc)?
1464188543
The Aaron
Forum Champion
API Scripter
Ok, #1 was an interesting problem to solve during an all hands meeting... =D Command: !marshal-tokens [ <token id> ... ] Select a bunch of tokens and run !marshal-tokens to build the tightest geometric shape for the given number of tokens.  Uses the "first" token as the top left corner (correcting its alignment if necessary).  You can also supply a group of token ids on the command line, or some combination of the two. Code: on('ready',function(){     "use strict";     var positioner=function(x,y){         var shell = (n) => Math.ceil(Math.sqrt(n)),             xyforn = (n) => {                 var s=shell(n),                     sm=s-1,                     sSeq=n-(Math.pow(sm,2)),                     pSeq=Math.ceil(sSeq/2);                 return {                     x: (sSeq%2 ? pSeq : s)-1,                     y: (sSeq%2 ? s : pSeq)-1                 };             },             startx=x,             starty=y,             count=0;                  return function(obj){             var coord=xyforn(++count);             obj.set({                 top: starty+(coord.y*70),                 left: startx+(coord.x*70)             });         };     },     normalizer=function(n) {         return (Math.max(0,Math.floor((n-35)/70))*70)+35;     };     on('chat:message',function(msg){         var cmd,ids,poser;         if('api' !== msg.type || !playerIsGM(msg.playerid) ){             return;         }         ids = msg.content.split(/\s+/);         cmd = ids.shift();         ids = _.union(ids, ((msg.selected && _.pluck(msg.selected,'_id')) || []) );         switch(cmd){             case '!marshal-tokens':                 _.chain(ids)                     .uniq()                     .map( (id) => getObj('graphic',id) )                     .reject(_.isUndefined)                     .tap(function(a){                         let o=_.first(a)||{get:()=>0},                             x=normalizer(o.get('left')),                             y=normalizer(o.get('top'));                         poser=positioner(x,y);                     })                     .each( poser);         }     }); });
1464189230
The Aaron
Forum Champion
API Scripter
Here's a gif of how it works, mainly because it looks kind of cool. =D  On drag select, I don't know how it determines "first."  Probably oldest token or deepest front to back.  Experimentation may  help you determine, or you can just shift-click them.
I know I can't use it (probably ever)... but that's pretty freaking awesome!
1464190122
The Aaron
Forum Champion
API Scripter
There may come a time when it's an option.  It would probably be great for games using napoleonic tactics (Warhammer, etc).  You might find yourself in a co-GM roll with a Pro subscriber, or maybe just upgrade for a special game some month (price of a pizza!).  =D Regardless, thanks!  I'm pretty pleased with the elegance of the math to build the ever expanding geometric shells. =D
You're the local Math Wizard, so of course you're able to do something involving moving things around into various geometric formations.
1464190520
The Aaron
Forum Champion
API Scripter
Hahahah!  I'd say that Brian or Silvyre are much more the math wizards.  I'll stick with Script Wizardry... =D
I'm trying to break my way into the Macro Wizardry section and make things that anyone will be able to use without too much effort. Right now, I can make attack/skill/spell queries that work, but they end up breaking the Sheet Roll buttons, but I'm fine with that drawback in order to consolidate everything.
1464194728

Edited 1464195080
This again, is absoulutely amazing and suits my needs perfectly. Basically I had ALOT of npcs moving through a dungeon. After fights and such it would takes ages to realign all of them into a tight cluster to have them moving together without them suddenly marching through walls from being too far apart etc to just end up fighting again and breaking the cluster etc. This is perfect, thank you. :)
1464196486
The Aaron
Forum Champion
API Scripter
np. =D Happy Rolling!
Now we want different shapes.  Hollow Squares, Circles, Triangle, Stars, Decagons...  (yes, I'm j/k).
1464371898
The Aaron
Forum Champion
API Scripter
Three of Swords said: Now we want different shapes.  Hollow Squares, Circles, Triangle, Stars, Decagons...  (yes, I'm j/k). Actually.... I was tempted to make a version where you could specify the number of columns or rows so that you could fill out units for something like Warhammer.  Also a version that did !rally-tokens in order to gather around a point.... There's lots of options... =D
That's one of the dangers of being able to make/use APIs... you've pretty much got unlimited choices when it comes to what you want to do; so much so that you can run the risk of it consuming your very life! (semi-kidding) I've done some coding before (not java) and it can be pretty addicting, or am I just weird like that?
1464413073
The Aaron
Forum Champion
API Scripter
Nope, spot on!  :)