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] AdvantageTracker v0.1.0 for 5th Edition Shaped Sheet 2.1.11+

1456721712

Edited 1456756531
This script is designed to use Ability macros to easily set the value of the Roll Options on the 5th Edition Shaped Sheet v2.1.11+ during play. &nbsp;Simply select a token then run one of the 4 options. !at --advantage This command will switch that selected character sheet to the "Roll with Advantage" option on the character sheet. &nbsp;A message is sent to chat that the character now has advantage. &nbsp;It also sets a green dot on the token giving a visual indicator that advantage is currently enabled. !at --normal This command will switch that selected character sheet to the "Roll 1 dice" option on the character sheet. A message is sent to chat that the character rolling normally. &nbsp;It removes any visual indicators (green/red dot) on the token. !at --disadvantage This command will switch that selected character sheet to the "Roll with Disadvantage" option on the character sheet. A message is sent to chat that the character now has disadvantage. It also sets a red dot on the token giving a visual indicator that disadvantage is currently enabled. !at --create This simply creates "Adv", "Norm", and "Dis" Ability macros for the selected character. &nbsp;These Ability macros simply run the commands above. &nbsp;Token Actions are enabled by default, but they could also be&nbsp;placed in the macro bar. !at --createquery This simply creates "Adv/Dis" Ability macro query for the selected character. These Ability macro query simply runs the commands above based on the option chosen in the query. Token Actions are enabled by default, but they could also be placed in the macro bar. There are 3 configuration options at the top of the script (config = default value): showAsTokenAction = true Setting true will automatically enable any newly created token actions. Setting false leaves newly created token actions disabled. advantageMarker = "green" &nbsp; disadvantageMarker = "red"; The full list of status markers that are available (in the same order they appear in the marker tray):&nbsp; "red", "blue", "green", "brown", "purple", "pink", "yellow", "dead", "skull", "sleepy", "half-heart", "half-haze", "interdiction",&nbsp;"snail", "lightning-helix", "spanner", "chained-heart", "chemical-bolt", "death-zone", "drink-me", "edge-crack", "ninja-mask", "stopwatch",&nbsp;"fishing-net", "overdrive", "strong", "fist", "padlock", "three-leaves", "fluffy-wing", "pummeled", "tread", "arrowed", "aura", "back-pain",&nbsp;"black-flag", "bleeding-eye", "bolt-shield", "broken-heart", "cobweb", "broken-shield", "flying-flag", "radioactive", "trophy", "broken-skull",&nbsp;"frozen-orb", "rolling-bomb", "white-tower", "grab", "screaming", "grenade", "sentry-gun", "all-for-one", "angel-outfit", "archery-target" Script can be found here: <a href="https://raw.githubusercontent.com/beeke01/Advantag" rel="nofollow">https://raw.githubusercontent.com/beeke01/Advantag</a>...
How about... Roll Options: !at --?{Roll|Normal,normal|w/Advantage,advantage|w/Disadvantage|disadvantage}
1456722823
Silvyre
Forum Champion
Simple and useful! Great!
HoneyBadger said: How about... Roll Options: !at --?{Roll|Normal,normal|w/Advantage,advantage|w/Disadvantage|disadvantage} That is a good option and would consolidate it down to one token action. &nbsp;I can probably add the option to create a query, or if people overwhelmingly prefer the query, simply make it the default.
Interesting, I may be able to incorporate this into my game... The issue is that a lot of things can give "Has advantage against target" but not advantage against anything else.&nbsp; I do like the concept though. I will need to think of some uses for it right now.
1456735248

Edited 1456736399
Kryx
Pro
Sheet Author
API Scripter
This is great! I'm glad there is more script support! The query is basically the same thing as one of the options on the sheet so it seems a bit silly to use a query from a button which just adds another step from the sheet version when your player specifically didn't like the query there. :P But from a usability perspective 1 click is better than a 3 click which would make me want to use the buttons. I would suggest shortening them to "Adv", "Dis", and "Nor".
@Saevar - I agree. &nbsp;For example the party casts Faerie Fire on a group, but only one in the group failed their save, so you only have advantage on that one. &nbsp;However, the way I look at this script it simply is a way to quickly and easily allow players to set their state without having to open the sheet. &nbsp;I my small test with one of my players, his work flow would be to keep things on normal, then if he had advantage on something swap into advantage, make the roll, then back to normal. &nbsp;It's a few clicks, but still faster and if the "always roll 2" doesn't appeal to some players, this seems like a reasonable option. @Kryx - I shortened the macro names to "Adv", "Norm", and "Dis". &nbsp;I also prefer the simplicity of a single click personally, however some people would prefer the query and remember this wouldn't be used with every roll, it's just a query to make the setting change on the sheet that will stay that way for a time.
Version 0.1.3 Shortened the names for the created token actions to "Adv", "Norm", and "Dis". Added a macro query option as an alternative to creating 3 macros. &nbsp;"--createquery" Added configuration that allows you to set the if the created token actions/queries is enabled by default. Added configuration that allows you to specify the status marker used for advantage and disadvantage.
Myself, I use standard (STD) when referring to a normal roll. It abbreviates better. :D
Version 0.1.4 Bug fix that addresses the case where the script would crash because "Roll Setting" was blank. &nbsp;This seems to happen on newly created sheets.
1456768970
Silvyre
Forum Champion
Haven't tried this, but would it be possible? Have players use an !at macro when they have adv/disadv Have a global attacher (!at --normal) reverse this
So is the intention to set adv/dis then after something is rolled, reset the value to normal? &nbsp;If yes... it's an interesting concept, though not certain how feasible it will be... need to think about it.
1456770279
Silvyre
Forum Champion
Well, really, they'd use !at from the Quick Bar, before they roll from the sheet, and then once they do, a global attacher would reset it automatically.
I don't think sheet attachers will run additional commands or macros. &nbsp;I think you could create an API button that would show up for the command, but the player would need to click it still.
I wonder though if you set a command word or something in the attacher and have an api script parsing the command looking for a specific word, which would then trigger the API to execute additional commands...
1456779015
Silvyre
Forum Champion
Kevin said: I don't think sheet attachers will run additional commands or macros. There's not (yet?) an option for a "freeform" attacher such that API chat commands can be appended at the end of a Roll Template? Kryyyyyyx! :P
There isn't that I am aware, but I am working on a concept that may work for this specific use case, getting closer.
1456823499

Edited 1456823520
Kryx
Pro
Sheet Author
API Scripter
What do you need me to change for a freeform thing? I added freeform on nearly everything on my sheet for your crazy ideas Silvyre! Opinion: "STD" is an awful abbreviation. Please, no. :P
1456823962
Silvyre
Forum Champion
Oh, nothing, nothing... I figured it out! :D
1456825964
Silvyre
Forum Champion
I also figured out that this works!
1456826177
Silvyre
Forum Champion
Could I just request the ability to hide announcements if !at --normal is used on a Character that is already rolling normally?
I can do that, but I don't think this will alleviate all of the challenges with this approach. &nbsp;First, there is a check to see if a token is selected, so if you just hit a button on the character sheet without a token selected, it will spam that message as well. I am also seeing a bit of a chat artifact, but I need to grab the latest sheet to make sure it just isn't with the version I have. &nbsp;(basically "0 0 0 0 0 0" is seen in the chat as well on an attack at least with the way I have it configured)
I have made the change so that messages will not spam if the user repeatedly hits the same command, so it will cover your case. &nbsp;But as I mentioned, you will still get the message that a token isn't selected if you don't have the token selected when you run the command. I thought about modifying the command to take a character and token id as a parameter, then you could use the command with these parameter in the sheet, however I wonder if you will end up with a workflow that actually benefits the users, particularly in the case where multiple rolls are required with advantage. &nbsp;For example, what about the case of a PC with multiple attacks, they would either have to reset advantage with each attack, or setup the attacher to not process attacks and remember to manually turn it off. &nbsp;I just wonder if it "auto-resetting" will be more annoying than helpful. You could comment out line 47 of the script to eliminate the message for not having a token selected... however if the token isn't selected, then it won't reset automatically... again so it may end up confusing players more than helping them. &nbsp;I am curious to see how it would play out with the setup in a real session.
Version 0.1.5: Prevented multiple chat messages by running the same command multiple times.
1456842382
Kryx
Pro
Sheet Author
API Scripter
Kevin said: For example, what about the case of a PC with multiple attacks, they would either have to reset advantage with each attack, or setup the attacher to not process attacks and remember to manually turn it off. &nbsp;I just wonder if it "auto-resetting" will be more annoying than helpful. Advantage can be for 1 thing in the case of inspiration, or for all of them in the case of environment or other circumstances. Assuming one or the other is a mistake. Let the user choose imo.
Kryx said: Advantage can be for 1 thing in the case of inspiration, or for all of them in the case of environment or other circumstances. Assuming one or the other is a mistake. Let the user choose imo. So I am not clear, are you for or against using an "auto-reset" feature?
1456843528
Kryx
Pro
Sheet Author
API Scripter
Not making assumptions about the end of advantage is what I'd suggest. So not in favor of an auto-reset feature under the current dynamics as I understand them (setting duration would just add an extra step).
1456857336

Edited 1456857745
Silvyre
Forum Champion
Kevin said: I thought about modifying the command to take a character and token id as a parameter , then you could use the command with these parameter in the sheet, however I wonder if you will end up with a workflow that actually benefits the users, particularly in the case where multiple rolls are required with advantage. Regardless of usecase, being able to bypass token selection using --@{character_id} would be glorious. Also, FYI @ Kevin, HoneyBadger: I'm only using the newest versions of PowerCards and AdvantageTracker in my test game (installed in that order), but I have to prepend AdvantageTracker with a semi-colon to prevent unexpected token.
Based on the fact that I am modifying the token to provide visual indicators means that I need both the character_id and token_id. &nbsp;I am not sure if there is a good way to get a characters token_id without specifically selecting a token (or providing it via @{target/selected|token_id}). I have it somewhat working now with "!ta --option --character_id --token_id" syntax, but honestly I need to refine it... it's a bit fragile. &nbsp;If you put in a bogus character or token id the script falls over. &nbsp;I need to find an efficient way to test for valid data. As far as needing to prepend my script with a semi-colon, I don't know what that is about, does the latest powercard script end with a semicolon? &nbsp;I am running several of my own scripts and don't see the same problem.
1456875809
Silvyre
Forum Champion
In my opinion, making token selection optional would be optimal; if no token is selected, no indicators are applied. The script is great as it is, though. Kevin said: As far as needing to prepend my script with a semi-colon, I don't know what that is about, does the latest powercard script end with a semicolon? PowerCards does not end with an extra semicolon (it does start with an extra one for "script error proofing", though). I just now added one to the end of PowerCards (instead of prepending AdvantageTracker) and that too prevents the error. I'll let HB know.
1456883163

Edited 1456883177
I have it setup now where specifying a token_id is optional... but this can leave you in a situation where status markers don't represent the actual status. &nbsp;For example you select the token, set advantage, then set normal without selecting a token or specifying a token_id, you end up in a state where you are rolling normally but the status markers still indicate advantage. I am not certain the best way to handle macro creation. &nbsp;I feel that it makes most sense to require selecting a token, this way there is full consistency from a character perspective by automatically adding the character_id and token_id to the macro, but let me know if you feel differently. &nbsp; GM's can now also run &nbsp;!at --&lt;option&gt; --@{target|character_id} --@{target|token_id} macros to easily change statuses or setup macros as well.
1456883472

Edited 1456883705
Version 0.2.0 Optional second parameter: &nbsp;--&lt;character_id&gt; &nbsp;i.e. --@{target|character_id} Optional third parameter: &nbsp;--&lt;token_id&gt; &nbsp;i.e. --@{target|token_id} Creating macros currently requires (pending feedback) selecting/specifying a character and token. &nbsp;Enforcing this allows me to automatically create Ability macros with the correct character_id and token_id, this way they can effectively be used from a character sheet or macro bar without selecting a token. NOTE: &nbsp; I plan to make a new post for this version, that way I can add details about the optional parameters. &nbsp;I tested all cases that I could think of, but adding these additional parameters added significant complexity to the script, so I would love it if a few people could put it through the paces and let me know if it works well or if it breaks down somewhere. &nbsp; I am not also thrilled with the readability of the code, so if any of the more experienced coders have suggestions, I would love to hear it.
Version 0.2.1 Fixed a bug with --create/--createquery options
1457129177
Falcon
Pro
Sheet Author
Quick question Kevin - can you select multiple tokens and run this?
No, unfortunately not.
1457130411
Silvyre
Forum Champion
Black Falcon said: can you select multiple tokens and run this? You could have a macro like this: !at --?{Roll|normal|advantage|disadvantage} --@{target|1st Target|character_id} --@{target|1st Target|token_id} !at --?{Roll} --@{target|2nd Target|character_id} --@{target|2nd Target|token_id} !at --?{Roll} --@{target|3rd Target|character_id} --@{target|3rd Target|token_id} !at --?{Roll} --@{target|4th Target|character_id} --@{target|4th Target|token_id} !at --?{Roll} --@{target|5th Target|character_id} --@{target|5th Target|token_id} !at --?{Roll} --@{target|6th Target|character_id} --@{target|6th Target|token_id} If you have less than 6 targets, just select one of them multiple times.
1457138819
Falcon
Pro
Sheet Author
Yeah that will work. &nbsp;Thanks Silvyre. &nbsp;Kevin - Love the idea of having APIs with character sheets. &nbsp;I am using both of yours.
Black Falcon said: Yeah that will work. &nbsp;Thanks Silvyre. &nbsp;Kevin - Love the idea of having APIs with character sheets. &nbsp;I am using both of yours. Glad that you like them. &nbsp;Let me know how they work out for you!
It would be possible to modify the script to use msg.selected on all the tokens you have selected instead of having to target each one individually.
Yeah, I am trying to figure that out as it would be a nice feature. &nbsp;It made me think that it would almost be nice to have a common functions library, because it seems like even in the minimal number of scripts I am working on, there are many things that I find I am doing consistently.
Something like... _.each(msg.selected, function (a) { // Do stuff... }); ... might work. I can't recall whether msg.selected is an object or array.
1457186100

Edited 1457186248
Selecting 3 tokens ends up with the following while logging msg.selected: [{"_id":"-K9sYm1pkNKfCmzvIgJQ","_type":"graphic"},{"_id":"-KB9Rd_RNskdm-UWd9LN","_type":"graphic"},{"_id":"-KBQALmfT2kG9VJ-RNCZ","_type":"graphic"}] So if I understand my JS terminology, this is an object. &nbsp;Can _.each be used with an object? &nbsp;I am pretty certain it can... just thinking I am doing something wrong, too tired to think straight right now (puppy woke me up too early).
Yeah it should. In the function above, a would be equal to {"_id": "", "_type" : ""} and you could use a.id I believe just to get that. I always have to double check this stuff every time I want to use it. I don't do enough scripting every day to just remember it off the top of my head like TheAaron.
1457192181
The Aaron
Pro
API Scripter
You're pretty much right, but it would be a._id as the dropping of _ on the front of properties is a roll20 thing.