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] Yet Another Automatic Initiative Tracker

July 16 (11 years ago)

Edited July 16 (11 years ago)
All the other scripts to do this task are either not automatic enough for me, or don't work for me, so I wrote my own:

The commands are:

!order
- To reorder the tracker in initiative order, for when you manually add something extra.

!clear
- Clears the tracker.

!init
- This will automatically start combat on the page where the players bookmark is placed.
- For every token on the objects layer that represents a PC, it will look for an "initiative" stat and use it as the modifier.
- For every token on the objects layer that does not represent a PC, it will use whatever value you have put as the value of bar 3 as the modifier. This way you don't have to add every single monster as an npc in the character list.
- If 2 things are tied, it will use the initiative modifier as the tiebreaker.

!togglelayer
- Will toggle selected tokens between GM layer <-> Object layer.

Remember to always download from the gist for the newest version.

https://gist.github.com/Villadelfia/ed297cf289472748f49a
July 16 (11 years ago)

Edited July 16 (11 years ago)
Edit: Weird. It does not seem to like another script. HOWEVER, it does work. I noticed that it's giving me decimal places? Any way to fix this?

The other script is:

// GIST: https://gist.github.com/shdwjk/48370c09788e11263d32/edit

Lucian Crey: I roll 18.5 (1d20+5.5) for initiative!
Lady Ardath: I roll 16.1 (1d20+12.1) for initiative!
Davok "Leather Face" Von'Drak: I roll 14.8 (1d20+8.8) for initiative!
Asclepius: I roll 11.2 (1d20+2.2) for initiative!
Cyrus: I roll 22.4 (1d20+4.4) for initiative!



^ The decimal places I was talking about.
July 16 (11 years ago)
The Aaron
Roll20 Production Team
API Scripter
What is the issue it's having with the other script?

Change line 54 to this to fix the decimal:
var roll = Math.round(parseFloat(JSON.parse(ops[0].content).total));
July 16 (11 years ago)

Edited July 16 (11 years ago)
I'm not sure about the other script. All it says is "Unexpected Identifier". If I disable one or the other, the scripts work. But, they seem to not like each other concurrently...


edit: Thank you so much re: the decimal. -- In the actual initiative tracker, there are no decimal places. But, it still shows in the chat that there are decimal places...

Lucian Crey: I roll 21 (1d20+5.5) for initiative!
Lady Ardath: I roll 19 (1d20+12.1) for initiative!
Davok "Leather Face" Von'Drak: I roll 11 (1d20+8.8) for initiative!
Asclepius: I roll 11 (1d20+2.2) for initiative!
Cyrus: I roll 14 (1d20+4.4) for initiative!


edit 2: Just realized that the text rolls ALWAYS stay the same (eg: 4.4 on Cyrus), regardless of what is actually rolled. Haha.

Aaron or Randy, it looks like it's this line: (76)

sendChat("character|"+currId, "I roll " + roll + " (" + ops[0].origRoll + ") for initiative!");
July 16 (11 years ago)

Edited July 16 (11 years ago)
The Aaron
Roll20 Production Team
API Scripter
Yeah, the origRoll is generated by roll20's dice mechanics.

You could do something like:
sendChat("character|"+currId, "I roll " + roll + " (" + ops[0].origRoll.split('.',2)[0] + ") for initiative!");
But that might cause issues if the origRoll gets to be more complicated.
July 16 (11 years ago)
The Aaron
Roll20 Production Team
API Scripter
I'm not sure what the problem is with that carry script. I'm not a big fan of that code, but there is nothing obviously wrong with it.

You could try putting a ; on the end of the last line and adding a few returns. Not sure if that will fix it, but it won't hurt it and it might..
I used the decimal places as a hack for when 2 people roll the same initiative. (In pathfinder, if 2 people roll the same, the person with the highest initiative bonus wins)

So, someone with an initiative of 7 would get "19.7" and someone with a bonus of 3 would get "19.3".

I have updated the gist so that you no longer get decimal places, it now puts the bonus in the ignored "custom" field, and uses it as a secondary sorting mechanism.
July 16 (11 years ago)

Edited July 16 (11 years ago)
The script you just gave me fixed the problem that I had with the decimal. The reason why I was using the Carry Script is because (I guess?) I need to use it for your animation (for some reason?). I guess the animation isn't super needed. But, thanks for helping Aaron. You rock.

the other script I use (the Carry Token) is the !tm
July 16 (11 years ago)

Edited July 16 (11 years ago)
Kuriin: Please check the gist for the newest version, I fixed the decimals, it now handles tiebreakers properly.

https://gist.github.com/Villadelfia/ed297cf289472748f49a/30a5dabb62d35cbb4ca0637425e79a13fa8db535
Yep! It's working beautifully, Randy. Thanks much. Can you tell me if this pulls from the actual character sheets or are they from the Attributes and Abilities in the character journal? That way I know what to tell people to update. -- Love it so I don't have to wait for people to roll, haha.
It uses the old attribute system for players. Just add a stat that's called "initiative" on every character.

For monsters, or any other token that's not bound to a character, it uses the value of Bar 3 (the red one) as the modifier.
Beautiful! Thanks much. That rocks my world.
Just an FYI -- the monsters (bar 3) doesn't seem to work. I put 7 as a random number in bar 3 and do the !init command and it doesn't add the monster's initiative.
July 16 (11 years ago)
The Aaron
Roll20 Production Team
API Scripter
Kuriin, you don't need that carry script for any of my scripts, but it was causing an issue with my turn marker script because of how it iterates through arrays. I adjusted it to solve that issue for you. =D
July 16 (11 years ago)

Edited July 16 (11 years ago)

Kuriin said:

Just an FYI -- the monsters (bar 3) doesn't seem to work. I put 7 as a random number in bar 3 and do the !init command and it doesn't add the monster's initiative.


The token needs to be on the object layer, and it needs to be on the page where the player bookmark is. Also, it needs to be the bar value. max doesn't need to be set.
Very cool. Thanks. :) That totally helped.
My bad, I forgot to mention that in the documentation.

I couldn't think of a use-case where you would want to start a combat without the players in the map.
sdsdsd