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

[Help] How to change a script to track movement of a token

I picked that script on the Roll20 help center: on("change:token", function(obj, prev) { //Only do this if we actually moved. if(obj.get("left") == prev["left"] && obj.get("top") == prev["top"]) return; obj.set({ light_radius: Math.floor(obj.get("light_radius") * 0.90) }); }); Would it be possible to change it for tracking the movement of a token, if the movement value is stored on the Bar3 of the token ?
Ok it was very easy to do ^^ on("change:token", function(obj, prev) {     //Only do this if we actually moved.     if(obj.get("left") == prev["left"] && obj.get("top") == prev["top"]) return;     obj.set({         bar3_value: Math.floor(obj.get("bar3_value") - 1)     }); }); Any idea if there is a way to activate/desactivate this function in game via a macro command ?
1586419889
The Aaron
Roll20 Production Team
API Scripter
To be able to toggle it off and on would require: 1) a place to store the setting (probably the state object, or encoded on the token somehow (status market, GM notes, etc) 2) an event handler for chat:message  events. 
I'll look for a way to do this because the function should only change the value for NPC and PC :)
I am surprise there is no existing script for tracking spend movement point, beside a very old one?
1586442558
The Aaron
Roll20 Production Team
API Scripter
Probably people that need to solve that problem just use the Measure Tool while moving with a press of the Q button.  I think it would make a great script, I'm looking forward to seeing what you come up with!
Sorry it was not my intention to appear contemptuous or haughty, English is not my mother tongue, and I certainly expressed myself badly. I have no pretensions and my programming skills are really basic. I just thought it was a basic feature (witch is certainly not) and there had to be a script for it, in view of the quantity of great scripts existing (like Token mods or Powercards). Alas my research did not give anything.  The measuring tool is great for a system where the movement is done only once, but if there are several phase of movement within the same turn, it is sometimes practical to be able to follow the amount of movement remaining.
1586525359
The Aaron
Roll20 Production Team
API Scripter
Oh!  I'm also sorry if that came across in a negative way, I didn't intend it that way! I didn't find anything wrong or negative with your statements! I was only pointing out possible alternatives and the reason I think this hasn't been addressed in a script. I am happy to help you figure out the best way to write one, I've even worked on some before.  The biggest problem I had was I couldn't think of a good way to handle changes in movement rate.  For example, you could have someone start off walking on difficult terrain, then fly some distance, then land of normal terrain, then climb, followed by swimming some distance, all having used a dash action for double movement and being under the effect of a haste spell. Throw in a bit of teleportation from the Mystic's Nomad Travel thing, and you've got a pretty tedious thing to try and calculate (and don't get me started in mounts...). In my case, I'm dealing with 5th Edition DnD, other systems may be more or less complicated.  It's much easier to figure out how far a token has moved and let a human assign the type of movement mentally. I though about writing a script that would show possible movement distances using auras or transparent drawings of concentric rings, but there's still the problem of difficult terrain or alternate movement forms causing those to be inaccurate.  Maybe your case is much simpler?  Tell me about the problem you're trying to solve and maybe we can come up with a way to make it easier in a script! Again, I'm sorry if I came across harshly, that wasn't my intent!