
Hi All, Running a Gaslands game, and I'm trying to streamline play and cut down on the fiddliness of the templates by automating the placement as much as possible. I found the link below: <a href="https://app.roll20.net/forum/post/9598932/dropping-graphic-adjacent-to-selected-char-token-matching-rotation/?pageforid=9598968#post-9598968" rel="nofollow">https://app.roll20.net/forum/post/9598932/dropping-graphic-adjacent-to-selected-char-token-matching-rotation/?pageforid=9598968#post-9598968</a> ...which seems like a great solution, but one that only works when all of the tokens are identical in size. Unfortunately, in the game I'm running, we've got a wide variety of vehicles of different sizes, so I don't know that this solution will work for me. Even more unfortunately, I can handle macros but not scripting... My ideal solve would be to have the template ("Medium Straight", "Gentle Turn (Left)", etc.) selected via a chat button. The button would trigger a macro that would: - Pull the appropriate template from the GM layer (via TokenMod); - Set the template's rotation to match that of the selected token (???); - Compute the Left, Top coordinates at which to place the template; - To do this, I think I'd need to somehow pull the height value of the selected token (halved) and add it to the height value of the chosen template (halved) to get the radius of a circle, then use sin and cos values to find the Left, Top coordinates (relative to the vehicle token) to place the template (via TokenMod); I can find the x, y position of the selected template using this script from TheAaron: <a href="https://app.roll20.net/forum/permalink/4610415/" rel="nofollow">https://app.roll20.net/forum/permalink/4610415/</a> on('ready', function(){
"use strict";
on('change:graphic',function(obj,prev){
if( ( _.contains(['gmlayer','objects'],obj.get('layer')) ) &&
( obj.get('left') !== prev.left || obj.get('top') !== prev.top) &&
obj.get('represents') ) {
let a=_.chain(findObjs({type: 'attribute',characterid: obj.get('represents')}))
.filter(a=>a.get('name').match(/^position-[xy]$/))
.each(a=>{
switch(a.get('name')){
case 'position-x':
a.set({current: obj.get('left')});
break;
case 'position-y':
a.set({current: obj.get('top')});
break;
}
});
}
});
}); But what I'm struggling with is the following: - Finding the rotation value of the token so I can match the template rotation to it; - Finding the height value of the token so I can compute the placement of the movement template; Any suggestions for how I can gather these values so I can cobble together a solve for this? Or is there a better approach that has already been explored and executed? Thanks in advance!