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

Is there a API script that allows you to move a selected token toward a target token?

1643828271

Edited 1643828306
I know you can use the TokenMod api to move tokens a certain distance and in a certain direction. Is there a way to move a selected token toward a target token? Thanks in advance.
1643833190
The Aaron
Roll20 Production Team
API Scripter
Nothing I can think of that's been written.  What's the use case, and how do you see it working?
1643838144

Edited 1643838437
The Aaron said: Nothing I can think of that's been written.  What's the use case, and how do you see it working? I will use my current encounter as an example: The "random" encounter they are facing along the road they are traveling is a bulette attack. I have successfully made it so when the bulette breaches the ground: A "hole" token is spawned on to the Map layer: simulating the visual effect of the breach. The bulette appearing on the Token layer: simulating the creature breaking through the ground. Audio of the ground being breached. What would be cool is to have it simulate movement (like waypoints) the 15ft (or however many ft) to either on top of the target token(s) or next the tokens from the point of breaching. Basically a way to make it look more immersive when monsters move. The way I imagine it working: Macro activates --you select the target --enter the amount of distance it travels toward the target --the token looks like it moves (like waypoints) to the targeted distance. OR an advanced version would allow you to click waypoints after the macro is activated without having to have a "target" token.
1643854811
The Aaron
Roll20 Production Team
API Scripter
Hmm.  I can't think of a way to write that where it wouldn't be more efficient (as in, fewer clicks and mouse moves, no typing, etc) to just grab the token and move it, possibly with waypoints dropped via the right click on the mouse.
1643862712
timmaugh
Forum Champion
API Scripter
I'm so tempted to try to meta this.
1643868443
Finds
API Scripter
Not sure it still works but KABOOM use to be able to either push away or pull in tokens  Script:KABOOM - Roll20 Wiki
I used tokenmod to pull off bait and switch from the battlemaster maneuvers, its clunky as hell but does something similar, you just have to know angles of directions in my macro.  
1643897887
timmaugh
Forum Champion
API Scripter
That's the part I was tempted to meta... because you can get the top, left, and width of TokenA and TokenB with Fetch. And if you plug those numbers into the right equation, you not only know the angle, you have a distance that you can break down into chunks.
The Aaron said: Hmm.  I can't think of a way to write that where it wouldn't be more efficient (as in, fewer clicks and mouse moves, no typing, etc) to just grab the token and move it, possibly with waypoints dropped via the right click on the mouse. I just like the idea of being able to click a button that would compile movement, attack, and fx into one simple interface.
My bait and switch macro rarely gets used precisely because of what TheAaron typed.  As the Dm its just easier for me to move them manually, but it does look pretty flashy when the /fx command and token mod statusmarkers application fire all at once with the movement.  Showmanship goes a long way towards justifying it but ultimately yeah..manually its just faster simpler for the DM to do it.