Here ya go. This will move in the direction of the Rotation Bar, up on an unrotated token. This lines up with the "forward" direction for light, so will work with it. (Quick tip, if your token is facing down, right click->advanced->flip vertical, right click->advanced->flip horizontal to get it the right way). Command is !mif (Move In Facing): !mif That will move all selected tokens one standard unit (70 pixels) in the facing direction. You can vary that by supplying an argument which is the number (decimals accepted) of units to move (negative numbers will move backwards): !mif 3 !mif 1.5 !mif -2 You can also use inline rolls: !mif [[1d3]] You can reference attributes, but bear in mind it won't be deterministic which attribute is referenced with multiple tokens selected: !mif [[@{selected|speed}]] Code: on('ready',()=>{
const processInlinerolls = (msg) => {
if(_.has(msg,'inlinerolls')){
return _.chain(msg.inlinerolls)
.reduce(function(m,v,k){
let ti=_.reduce(v.results.rolls,function(m2,v2){
if(_.has(v2,'table')){
m2.push(_.reduce(v2.results,function(m3,v3){
m3.push(v3.tableItem.name);
return m3;
},[]).join(', '));
}
return m2;
},[]).join(', ');
m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;
return m;
},{})
.reduce(function(m,v,k){
return m.replace(k,v);
},msg.content)
.value();
} else {
return msg.content;
}
};
on('chat:message', (msg) => {
if('api' === msg.type && /^!mif\b/i.test(msg.content)){
let args = processInlinerolls(msg).split(/\s+/);
msg.selected
.map((o)=>getObj('graphic',o._id))
.filter((t)=>undefined !== t)
.forEach(t=>{
let angle = ((parseFloat(t.get('rotation'))||0)-90) * (Math.PI/180);
let distance = 70*(args[1]||1);
let x = t.get('left')+(distance*Math.cos(angle));
let y = t.get('top')+(distance*Math.sin(angle));
t.set({
top: y,
left: x
});
});
}
});
});