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

Method for Passing Direction to API

1511166913

Edited 1511171133
Bast L.
API Scripter
So, suppose I wanted a macro to pass a command, a selected origin token, and a direction to an API script. Is there a way to use a macro query to get that direction, similar to getting targets? Edit: oh, and if there is a method, can you get distance from it as well? As in the length of the directional arrow? To be clear, I mean the direction and length of this line pictured below:
1511471297
The Aaron
Pro
API Scripter
So, I can think of a few ways to do this. (Sorry for the delay, vacationing this week!) 1) draw the line and select it and the token then run the command. The api will get both objects in the msg.selected field, which you can use for the input.  2) have the command spawn a cursor token which the command issuer is given control of, have them move it into place indicating distance and direction (optionally daw a path for it when they move it) and then issue a command to complete it (possible as a token action or some other manipulation like deleting or rotating).  3) specify relative coordinates with the command. Could use cartesian (-3,6)  or polar (120°,5) or something else. 
Yeah, I was thinking it would spawn a token anyways (an AOE template), but for ease of use, I had hoped the fx aiming tool could pass info. Polar coordinates seem like the simplest option, as the ruler will show the distance, and the players can guess the angle. There's no "last position clicked" property, is there? I know that pasted tokens appear at the last clicked position, but we don't have access to that in the API, do we?
1511486509
The Aaron
Pro
API Scripter
We do not. 
1511486654
The Aaron
Pro
API Scripter
You could use the token’s Last Move. Basically, move the token to the position, run the command and it takes the position, moves the token back where it last moves from, and uses the vector for the direction. A little strange, but might be pretty expedient after a few times doing it.