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

Request patrolling token on initiative instead of timer

My group is chat based, and I always ask them to move their tokens using the space bar thing, but I was wondering (As I've gotten very little exposure to being a mentor), if there was a way to make the patrolling tokens move on an initiative tracker instead of seconds.
1403027079

Edited 1403491589
The Aaron
Roll20 Production Team
API Scripter
Definitely. There would be some wiring that needs to happen, but you'd just need to use something like: on('change:campaign:turnorder',function(obj,prev) { // get current turn var turns=JSON.parse(Campaign().get("turnorder")); if(undefined != turns && turns.length && -1 !== turns[0].id ) { // check if ID is one of the tokens you're automating // run a function that moves them on their path the next increment } });
Would I just plug that in? I'm not a pro with scripts. Would you mind posting the edited script for me?
1403491296

Edited 1403491393
That is the "script," but it is unfinished and requires some editing. He basically provided you with a means of parsing the turnorder, with a place to do some actions (in the if statement)
1403492021
The Aaron
Roll20 Production Team
API Scripter
Yeah, sorry, I was just giving you a head start. That snippet will get activated whenever the turn order changes. That could be because the turn is advanced, or because it got sorted, or someone's initiative changed, or you dragged the position of someone around. You'll probably want to check that the id of the first person in the obj parameter and the first person in the prev parameter are different before proceeding into the body. ( Heads up, the obj is a full fledged Roll20 object, the prev is a simple javascript object. You need to use obj .get('thing'), and prev .thing to access thier respective values. ) Once inside the body, you will need to look at the id of the first person in the turn order, and check it against a list of token ids that are patrolling. If it is one of your patrollers, just move them where they need to be. I don't recall specifically, but the move logic should be in the existing script already, so you should be able to just call it for the id you're looking at. Let me know if that's outside your scripting abilities and I'll see if I can help out. Cheers!
Does turnorder have the ability to return the id of who holds the current initiative?
1403527404
The Aaron
Roll20 Production Team
API Scripter
Turn order is just a JSON string of a list of objects. The first object is the person at the top of the turn order and includes whatever their priority is. So you can tell who is at the top, and the list is in whatever order the the turn order is in. Does that answer your question?