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] CombatTracker

Testing 1.1.3, doesn't seem to have fixed either issue unfortunately. Here's the relevant API output. Trying to apply Dazed to a token, entering 5 for the Duration query and -1 for the Direction query: "handleInput" "Msg:!ct add dazed 5 -1" "handleInput" "Command:ct" "Action:add" "Condition:dazed" "Changes:5" "Key:undefined" "Value:undefined" "Duration:-1" "Direction:undefined" "Add Command" "Condition:dazed" "Duration:-1" "Direction:undefined" "ID:-LjEA-B-S6oaEJT2s_C4" "Type:graphic" "Add Condition" "Token:-LjEA-B-S6oaEJT2s_C4" "Name:dazed" "Duration:-1" "Direction:undefined" "Remove Condition" "Name:dazed" "Combat Conditions" "Duration:-1" "Direction:0" "Send Condition To Chat" "Combat Conditions" {"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":-1,"direction":0} Manually adding Dazed and Confused to the token by adding a item between Condition and Duration, setting duration for both as 5: "handleInput" "Msg:!ct add dazed _ 5 -1" "handleInput" "Command:ct" "Action:add" "Condition:dazed" "Changes:_" "Key:undefined" "Value:undefined" "Duration:5" "Direction:-1" "Add Command" "Condition:dazed" "Duration:5" "Direction:-1" "ID:-LjEA-B-S6oaEJT2s_C4" "Type:graphic" "Add Condition" "Token:-LjEA-B-S6oaEJT2s_C4" "Name:dazed" "Duration:5" "Direction:-1" "Remove Condition" "Name:dazed" "Combat Conditions" "Duration:5" "Direction:-1" "Send Condition To Chat" "Combat Conditions" {"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1} "handleInput" "Msg:!ct add confused _ 5 -1" "handleInput" "Command:ct" "Action:add" "Condition:confused" "Changes:_" "Key:undefined" "Value:undefined" "Duration:5" "Direction:-1" "Add Command" "Condition:confused" "Duration:5" "Direction:-1" "ID:-LjEA-B-S6oaEJT2s_C4" "Type:graphic" "Add Condition" "Token:-LjEA-B-S6oaEJT2s_C4" "Name:confused" "Duration:5" "Direction:-1" "Remove Condition" "Name:confused" "Combat Conditions" {"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1} "Duration:5" "Direction:-1" "Send Condition To Chat" "Combat Conditions" {"id":"-LjEA-B-S6oaEJT2s_C4","name":"dazed","icon":"aura","duration":5,"direction":-1} {"id":"-LjEA-B-S6oaEJT2s_C4","name":"confused","icon":"bolt-shield","duration":5,"direction":-1} Fifth turn, when both conditions should be removed: "Turn Order Change" "ID:-LjEA-B-S6oaEJT2s_C4" "Announce Condition" "Token ID:-LjEA-B-S6oaEJT2s_C4" "Condition:dazed" "Duration:1" "Direction:-1" "Remove Condition" "Name:dazed" "Combat Conditions" {"id":"-LjEA-B-S6oaEJT2s_C4","name":"confused","icon":"bolt-shield","duration":1,"direction":-1}
1564317104
Victor B.
Pro
Sheet Author
API Scripter
I've found the issue, just not sure yet how to fix it.  As it's looping through the conditions and matching up to tokens, I'm removing conditions from the same array and forEach is stopping and not processing the last line.  
Thanks for the update! That is odd that forEach isn't processing each line on the same turn.. Also, I noticed in the output I shared, it seems that in the command '!ct add dazed 5 -1', the 5 is being processed as "Changes" instead of Duration. What does Changes do?
1564326574
Victor B.
Pro
Sheet Author
API Scripter
When you manipulate an array at the same time you are iterating through it, javascript can get confused.  This is the case, just not sure yet how to fix it.  
1564328043

Edited 1564328175
Victor B.
Pro
Sheet Author
API Scripter
New version here, 1.1.4 Beta&nbsp; <a href="https://github.com/vicberg/Combattracker" rel="nofollow">https://github.com/vicberg/Combattracker</a> Through TheAaron's help, found a solution to the last condition being skipped.&nbsp; Last condition is now being removed.&nbsp; I also changed logging for the command parsing to be more relevant.&nbsp; When doing an add condition command, the log on changes won't show and cause possible confusion.&nbsp;&nbsp;
Testing 1.1.4, all conditions are being removed when they're supposed to! But I still have to add a placeholder between Condition and Duration in the command. Without the placeholder, the Duration is still being ignored, with Direction being parsed as Duration and then nothing being used for Direction. "Announce Condition" "Token ID:-LjE9yautiV8a0CWMF-B" "handleInput" "Msg:!ct add dazed 5 -1" "handleInput" "Command:ct" "Action:add" "Condition:dazed" "Duration:-1" "Direction:undefined" "Add Command" "Condition:dazed" "Duration:-1" "Direction:undefined" "ID:-LjE9yautiV8a0CWMF-B" "Type:graphic" "Add Condition" "Token:-LjE9yautiV8a0CWMF-B" "Name:dazed" "Duration:-1" "Direction:undefined" "Remove Condition" "Name:dazed" "Combat Conditions" "Duration:-1" "Direction:0" "Send Condition To Chat" "Combat Conditions" {"id":"-LjE9yautiV8a0CWMF-B","name":"dazed","icon":"aura","duration":-1,"direction":0}
1564356134
Victor B.
Pro
Sheet Author
API Scripter
1.1.5 is up now and will take care of that issue
Great work Victor, thank you for getting all of that cleared up! I'm not having any issues with 1.1.5, everything is running smoothly with my testing so far :)
I was testing conditions tonight when I ran into this error: RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at RegExp.exec (&lt;anonymous&gt;) at RegExp.test (native) at ac (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:71) at $b (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:36:239) at mc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:40:370) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:44) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133) at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133)
1564403894
Victor B.
Pro
Sheet Author
API Scripter
@Professor, is this a consistent error?&nbsp;&nbsp;
This is the first time I have seen it. Let me see if I can get it to come up again, I'll report back.&nbsp;
I did not get that same error, I did have this one: TypeError: Cannot read property 'id' of undefined TypeError: Cannot read property 'id' of undefined at handleGraphicMovement (apiscript.js:8936:33) at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:151:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:151:1), &lt;anonymous&gt;:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:1020:14) at updateLocalCache (/home/node/d20-api-server/api.js:1318:18) at /home/node/d20-api-server/api.js:1502:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Rd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
1564436102
Victor B.
Pro
Sheet Author
API Scripter
These are more intermittent issues.&nbsp; I'm thinking I may need to reach out to the scriptomancer (The Aaron) to figure these out.&nbsp;&nbsp;
Is it possible to add an ID to the command so that I could have a macro that makes a character automatically add an exhausted condition to themselves at the end of a special attack? Or does this mod require having the token selected?
1564495661
The Aaron
Roll20 Production Team
API Scripter
Victor B. said: These are more intermittent issues.&nbsp; I'm thinking I may need to reach out to the scriptomancer (The Aaron) to figure these out.&nbsp;&nbsp; I'll be off Thursday–Sunday, hit me up on Discord. =D
1564506584
Victor B.
Pro
Sheet Author
API Scripter
@The Aaron.&nbsp; Will do.&nbsp; @Stellan, currently only operates on selected tokens.&nbsp; I could see an integration with Token Mod to do that.&nbsp; I'm getting my arms around Token Mod as I've started the User Interface.&nbsp;&nbsp;
Fair enough. I would love to be able to use the add command with an id so I could use macros and character sheet commands to also apply status effects.
Victor, I noticed a tiny bug: the very first time I start combat during a session, it starts on round 2. After that, any time I start new combat, it starts on round 1 as it should.
1564853554

Edited 1564853727
I've notice a bug that when I start combat, it shows the token I have selected instead of "Round 1" in the chat.&nbsp; After that, it works correctly. Also, sometimes there is a rounding error in the initiative roll.&nbsp; I do have it set to add the dex to the initiative roll for tie breakers.
1564963878
Victor B.
Pro
Sheet Author
API Scripter
That's a strange roll.&nbsp; And yes, I'll find out what's going on with the round 2 start.&nbsp;&nbsp;
1564975232
The Aaron
Roll20 Production Team
API Scripter
That long number is IEEE754 rounding errors at work. You can avoid it by formatting the final number to a specific number of decimal places: pr: (initiativeMod + initiativeRoll).toFixed(2)
1565013412
Victor B.
Pro
Sheet Author
API Scripter
Thank you!
Feature request In the original combat tracker, since conditions weren't preset it would prompt a query for the name of the condition along with it's duration etc. These conditions weren't linked to status icons, either. Could a similar function be added to the new version, if it's generally useful enough? Maybe with a command syntax like !ct add ?{Name} ?{Duration|1} ?{Direction|0} I've found myself wishing for this function when things come into play like unique spell effects (especially ability buffs). There's not enough status icons to cover all these possibilities, so it would be really convenient being able to apply a condition/buff that doesn't use an icon and only appears in the turn announcement so it's duration can be tracked. Or if it's simpler, making status icons an optional feature for conditions? That way more can be added without being limited to the number of status icons.
1565094074
Victor B.
Pro
Sheet Author
API Scripter
That's an interesting idea.&nbsp; I'll consider it.&nbsp; There wouldn't be a status icon on the token, but the buff (or whatever) would be tracked none the less.&nbsp;&nbsp;
1565096175
The Aaron
Roll20 Production Team
API Scripter
You could choose one of the colors to represent generics and use its number to tell you how many generics are active on the token.&nbsp;
Victor B. said: That's an interesting idea.&nbsp; I'll consider it.&nbsp; There wouldn't be a status icon on the token, but the buff (or whatever) would be tracked none the less.&nbsp;&nbsp; Yes, this would be especially useful for tracking things in NPCs like an ability or attack buff that lasts so many rounds. I figure the name of such a temporary condition will need to have no spaces in order to not interrupt the syntax if the command. So when queried for the name of the condition I could put "+1atk" or "StrBuff" or whatever. The Aaron said: You could choose one of the colors to represent generics and use its number to tell you how many generics are active on the token.&nbsp; Only issue here I think is that Combat Tracker uses the numbers on status markers to indicate the duration.
1565119479

Edited 1565119512
Victor B.
Pro
Sheet Author
API Scripter
It would still work.&nbsp; If you set direction to 0, its tracking the number of that condition on the token.&nbsp; 3 bleeding conditions for example which don't go down over time, so direction is set to 0 and it remains at 3 until another character does something, like a heal.&nbsp; So the same concept could apply for generics.&nbsp; The number of generics on a token.&nbsp;&nbsp;
1565140544

Edited 1565140770
Oh, I see. So could the script have the icon with a static number even if some of the generic buffs have a direction of -1 themselves? Like, purple icon with number 4 to represent 4 buffs, each with it's own duration ticking down each round?
1565199054

Edited 1565199230
Victor B.
Pro
Sheet Author
API Scripter
If you are using a single icon to track generic buffs, and then you want differing durations all counting down, what do you display on the icon?&nbsp; I would assume the number is just showing the number of generic buffs.&nbsp; At that point, it's possible to then have different duration and different directions for each generic buff and those would display when announcing the player turn.&nbsp;&nbsp;
That would be ideal. I was concerned that generics with a -1 direction might interfere and cause the icon's number to reduce over time.
Seph if you make your macro using lowcase for the 1st letter it may for better. I just had to change mine to look like this.&nbsp; !ct add ?{Condition?|blinded|charmed|deafened|frightened|grappled|incapacitate|inspiration|invisibility|paralyzed|petrified|poisoned|prone|restrained|stunned|unconscious|bloodied|blessed|bardic-inspiration|raging|dodging|ready|surprised|hunter's-mark|faerie-fire|hex|reckless|haste} 0 0
It seem when every you add a condition it opens the Turntracker and unless it is open you can not remove conditions. It there a way to prevent this?
1565294693
Victor B.
Pro
Sheet Author
API Scripter
By turntracker, do you mean the turnorder window that shows the order of the players?&nbsp; That does not happen for me at all.&nbsp; I'm able to add and remove conditions without combat tracker started or the turnorder window visible or not.&nbsp;&nbsp;
Selecting the token then adding the icon from the token menu doesn't open it but adding from the Chat menu it seems to or even with the macro posted earlier. I am assuming it is because it is using the CT API command at that point. but could be wrong.
1565295520

Edited 1565295576
Victor B.
Pro
Sheet Author
API Scripter
You're macro is opening the turnorder window?&nbsp; I'm not sure CT is doing that.&nbsp; CT only opens the turnorder window when your start combat.&nbsp; What other APIs are you running?&nbsp;&nbsp;
But it does it from the chat window as well not just from the macro. granted it is the same command that is used. But if I have the CT menu open and add a condition it opens the Turn Order window. If selecting the token and going to the icon and adding it the Turn Order doesn't open. [If that is clear? :)]
1565296755
Victor B.
Pro
Sheet Author
API Scripter
Yes, but I can't replicate it.&nbsp; Something is forcing your Turn Order Window open.&nbsp; Any chance you can make a copy of your game and invite me?&nbsp; Promote me to GM once I join
Sent
I'm still seeing the first person in combat appear before the initiative rolls. In a large combat this means we're scrolling up to find the first check mark. Can all of the turns come after the rolls?
1565310808

Edited 1565311126
Victor B.
Pro
Sheet Author
API Scripter
Yes - UGG - this is async at work.&nbsp; The initiative process is firing before the doturnorderchange and guess what, doturnorderhchange is firing before the rollinitiative is done.&nbsp; Not as easy to fix
1565311464
Victor B.
Pro
Sheet Author
API Scripter
I'd have to put a flag in to check it is set before issuing the announce player.&nbsp; This might work
1565444005
Victor B.
Pro
Sheet Author
API Scripter
Release 1.1.6 Beta is available here&nbsp; <a href="https://github.com/vicberg/Combattracker" rel="nofollow">https://github.com/vicberg/Combattracker</a> Fixed - Rounding Error with decimals (thanks theAaron) - Fixed display issue where the first player was showing before the initiative rolls As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).&nbsp; It worked and I can assign in multiple.&nbsp; The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.&nbsp;&nbsp;
1565577938

Edited 1565595469
Victor B. said: As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).&nbsp; It worked and I can assign in multiple.&nbsp; The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.&nbsp;&nbsp; Awesome! Is this something you added, or it just happened to already work that way? It's just what I need, and working great. Thanks for letting me know this works!
Victor B. said: Release 1.1.6 Beta is available here&nbsp; <a href="https://github.com/vicberg/Combattracker" rel="nofollow">https://github.com/vicberg/Combattracker</a> Fixed - Rounding Error with decimals (thanks theAaron) - Fixed display issue where the first player was showing before the initiative rolls As far as placing conditions with no icons, I tied creating a bunch of conditions using the same icon (brown color).&nbsp; It worked and I can assign in multiple.&nbsp; The duration will be the latest assigned, but the other conditions are still there and will count down and display when the characters turn comes up.&nbsp;&nbsp; Sweet! Looking good Victor.
1565623818
Victor B.
Pro
Sheet Author
API Scripter
@Seph, it just happened to work that way.&nbsp;&nbsp;
The marker image isnt showing up when combat starts
FracturedSolace said: The marker image isnt showing up when combat starts Make sure you're testing on the page with the player ribbon, it won't work otherwise.
ah my bad thanks
1565917846

Edited 1565917863
Getting this error when trying to set a condition: The condition you are trying to use has not been setup yet I'm absolutely sure its something I've missed in the config, but can't seem to find it. Thanks!
1565923683

Edited 1565923811
Victor B.
Pro
Sheet Author
API Scripter
It means you haven't fully setup the condition.&nbsp; Open it by clicking on the little cog icon to the far right of the condition in question and you'll see that there's some missing values.&nbsp; They have to be set before you can use the condition.&nbsp; You need to set these for ALL conditions you are using.&nbsp;&nbsp;