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

[Script Request] Does the API have access to track movement command?

Can a script be written that functions like hitting the space bar anytime a player/GM drags a token into a new square? When doing this manually, hitting the space bar lays down a dot that tracks which square/space the character enters and tallies the total distance moved. In order to not interfere with all the tokens a GM must move, it would nice if it could be toggled on/off.
1424471700
Lithl
Pro
Sheet Author
API Scripter
Tokens have a "lastmove" property that you can write. I don't believe it will display the path and animate moving the token as though you had moved it along a path manually, but rather would let you show the path to someone who selected the token and hit space to display the path.
Is there a way for an API to simulate the same action as pressing the space button when you click drag hover and token into a new space?
1424486987
Lithl
Pro
Sheet Author
API Scripter
I suppose you could move the token to the next waypoint, delay, move to the next waypoint, delay, etc. You could then set the lastmove property to display the path taken. You could even throw up a drawing of the path if you wanted, although that would get trickier.
1424516326

Edited 1424516398
Lithl
Pro
Sheet Author
API Scripter
Here we go ! That'll let you move all selected tokens in terms of squares, feet (or whatever unit is set on the page), or pixels, depending on a GM-set mode. Example usage: !movetok 3 0,3 -3 0,-3 That would move each of the selected tokens in a 3x3 square clockwise starting and ending at the top-left corner. The token will move to each waypoint and sit there for 600ms (3/5ths of a second) before continuing to the next waypoint, which seems to be a decent approximation of the animation you see when someone else moves a token along a waypoint path manually. The script will also throw up a yellow path object to show the route, and the tokens' lastmove property will be set appropriately, so if you select the token and hit space after running the command, you'll see the path again. The script is currently awaiting merge into the scripts repo. Until then, you can find it at <a href="https://github.com/Lithl/roll20-api-scripts/blob/slide-tokens/Slide%20Tokens/Slide%20Tokens.js" rel="nofollow">https://github.com/Lithl/roll20-api-scripts/blob/slide-tokens/Slide%20Tokens/Slide%20Tokens.js</a>
Look forward to trying this out. Thanks! I'll let you know how it goes.