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] Units Moved

1369211881
Konrad J.
Pro
API Scripter
I thought I'd share this really quick little script I made.  Its basically the start of a larger more encompassing script. All it does is tell you how many units you moved a token.  At the moment it only works on a grid and a grid sized at 70 pixels/unit. But thats easy enough to make work with any scale, grid size, etc.  Even non grids. It calculates each diagonal as 1.5 units.  This is equivalent to the D&D/Pathfinder 1 unit then 2 units diagonal moves.  The reason I use 1.5 is so that the player can do a bunch of little moves and total them up to get his final movement total, and then round down to get the final true value.  This way no need to remember if they just moved one or two diagonals.  And if you moved too far, just press ctrl Z and it moves you back to where you are. Well here it is, hopefully it grows into a much larger more useful script.  I do have plans for the little guy. :) on("change:graphic", function(obj, prev) {     var xDif = 0; var yDif = 0; var diag = 0; var straight = 0; var unitsMoved = 0; if (obj.get("left") != prev["left"] || obj.get("top") != prev["top"]) { xDif = Math.abs(obj.get("left")/70 - prev["left"]/70); yDif = Math.abs(obj.get("top")/70 - prev["top"]/70); if (xDif > yDif) { diag = yDif; straight = xDif-yDif; } else { diag = xDif; straight = yDif-xDif; } unitsMoved = (diag * 1.5) + straight; sendChat("", obj.get("name") + " moved " + unitsMoved + " units"); } });
1369421301
Konrad J.
Pro
API Scripter
Here is a video of my latest verison of the script.&nbsp; I am really happy with it.&nbsp; Next I will add the option if you move past your alloted movement it moves you back. <a href="http://youtu.be/_u2Fu_N_1eI" rel="nofollow">http://youtu.be/_u2Fu_N_1eI</a>
Brilliant work! I have noticed that the combats in my campaign tend to stall when players are trying to figure out how far they can move. This will be very effective at saving precious time during a session. Well done!
That looks fantastic, well done! I'd love to see the more recent version of the script as well. I've been working on tracking time passed while exploring a dungeon, mostly so I know when torches go out and when to check for wandering monsters, and I haven't had many great ideas for how to automate the time that passes while characters are just moving through the dungeon. I think I'll just use your idea. I would use this script on a GM-only token, and set the move limit much higher -- whatever distance the party could explore in X amount of time, assuming they're mapping, checking for traps, trying to be quiet, etc. Then I just move the token along with the party, and it tracks how much distance remains until they've spent X time exploring. When the token runs out of movement, wandering monster check!&nbsp; Or something like that. Anyway, again, I'd love to see the code so I can shamelessly steal your ideas. ;-)
1369456592
Konrad J.
Pro
API Scripter
Callum M. said: Brilliant work! I have noticed that the combats in my campaign tend to stall when players are trying to figure out how far they can move. This will be very effective at saving precious time during a session. Well done! Thanks. &nbsp;I'm really happy on how it has come out so far. &nbsp;Things are a bit clunky for initial setup and at the moment it would only track one token at a time.
1369456896
Konrad J.
Pro
API Scripter
Brian H. said: That looks fantastic, well done! I'd love to see the more recent version of the script as well. I've been working on tracking time passed while exploring a dungeon, mostly so I know when torches go out and when to check for wandering monsters, and I haven't had many great ideas for how to automate the time that passes while characters are just moving through the dungeon. I think I'll just use your idea. I would use this script on a GM-only token, and set the move limit much higher -- whatever distance the party could explore in X amount of time, assuming they're mapping, checking for traps, trying to be quiet, etc. Then I just move the token along with the party, and it tracks how much distance remains until they've spent X time exploring. When the token runs out of movement, wandering monster check!&nbsp; Or something like that. Anyway, again, I'd love to see the code so I can shamelessly steal your ideas. ;-) Thanks again! &nbsp;I will be posting. &nbsp;I've actually been putting all my scripts together into one long script I've been calling Roll20 Framework (I need a better name). &nbsp;I might post it this weekend if I have time to get the docs written up. &nbsp;One other problem with all the scripts is I haven't put in error detection so they are all breakable fairly easy. &nbsp;I need to spend a bunch of time and put that in! There is no stealing of ideas, its sharing. &nbsp;Its all there for anyone to take and have fun with.
Just me posting my bit o input here, replaces line 19. &nbsp; sendChat("", obj.get("name") + " moved " + (Math.floor(unitsMoved)*5) + " feet"); basically just rounds down the final amount moved eith math.floor to get rid of the half-number (which we all know doesn't actually exist until the second diagonal is moved, so its not really being 'lost')&nbsp; then converts the distance moved into feet. for easy reference.
Konrad J. said: Here is a video of my latest verison of the script.&nbsp; I am really happy with it.&nbsp; Next I will add the option if you move past your alloted movement it moves you back. Ok, maybe I'm blind, but where is this "latest version"? Because the one in the OP is not it.
Quatar said: Konrad J. said: Here is a video of my latest verison of the script.&nbsp; I am really happy with it.&nbsp; Next I will add the option if you move past your alloted movement it moves you back. Ok, maybe I'm blind, but where is this "latest version"? Because the one in the OP is not it. In the video... duh. This feature looks pretty cool, but the problem is that in the case that the player makes a wrong move and wants to go back (at least from the looks of it) you cannot, which sadly sucks. Perhaps you should create key shortcut or a button for going back and thus going back to a previous position and recovering lost movement distance.
1370710110
Konrad J.
Pro
API Scripter
Quatar said: Konrad J. said: Here is a video of my latest verison of the script.&nbsp; I am really happy with it.&nbsp; Next I will add the option if you move past your alloted movement it moves you back. Ok, maybe I'm blind, but where is this "latest version"? Because the one in the OP is not it. Sorry, I haven't posted anything new just yet. &nbsp;Its all done, but I need to write up some docs. &nbsp;Its also incorporated with a few of my other scripts. &nbsp;I also want to add more waypoints and the ability to reverse your moves. &nbsp;Both fairly easy to do. &nbsp;I've just been busy at work and probably won't get anything done for a week or so. There is another user that has done something similar you could try. &nbsp;I really want to put mine out, I'm just too busy just right now. :(
This is a great script! I play D&amp;D 4E, so I changed the diagonal movement to equal 1, same as straight, and units into squares, but it there also an way to have the chat announcement sent only to whoever is moving the token. This is such a useful feature, but I imagine it flooding the chat screen when it is the DM moving a group of minions. Thanks!&nbsp;