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 with adjusting DeathTracker script to only apply marker to token on current page.

Currently the DeathTracker script checks if a token's health bar is at 0 or lower, then applies a marker to signify that the character is KO'd, but it applies the marker to every copy of the token across all pages. I'm also running CombatMaster which prints an announcement to chat when a marker is added to a token, detailing the effects of the related condition. When a PC reaches 0 health, it changes on all linked tokens, triggering DeathTracker to put a marker on each token, each of which triggers CombatMaster, causing a flood of chat announcements. I'd prefer to avoid deleting all player's tokens that aren't on the current page, and I also want avoid unlinking their tokens or health bars, so I'm hoping adjusting the script to only apply a marker to the token on the current page is easier than it sounds. If anyone has ideas or suggestions, I would love to hear them!
Persephone said: Currently the DeathTracker script checks if a token's health bar is at 0 or lower, then applies a marker to signify that the character is KO'd, but it applies the marker to every copy of the token across all pages. I'm also running CombatMaster which prints an announcement to chat when a marker is added to a token, detailing the effects of the related condition. When a PC reaches 0 health, it changes on all linked tokens, triggering DeathTracker to put a marker on each token, each of which triggers CombatMaster, causing a flood of chat announcements. I'd prefer to avoid deleting all player's tokens that aren't on the current page, and I also want avoid unlinking their tokens or health bars, so I'm hoping adjusting the script to only apply a marker to the token on the current page is easier than it sounds. If anyone has ideas or suggestions, I would love to hear them! Looking at the script I believe it uses the the getobj function that gets all token values in the game, its not specific to a page. It specifically looks for controlled by, and playeris. Off hand I did not see it check for a pageid either using the page or campaign functions of the api. So its likely you would have to modify the script to check to apply the change only where he current player ribbon is. Exactly how to do that Thescriptomancer The Aaron would be the best person to ask as I am novice when it comes to scripting, I can modify small changes and understand the some of the concepts. I used this&nbsp; <a href="https://roll20.zendesk.com/hc/en-us/articles/360037772793" rel="nofollow">https://roll20.zendesk.com/hc/en-us/articles/360037772793</a> &nbsp;as basis for understanding. Hope that helps point you in the right direction.
1587228801
The Aaron
Roll20 Production Team
API Scripter
This is an interesting issue.&nbsp; The change is propagated to other pages by changing the bar value which then changes the linked attribute, which then changes the bars on all the linked tokens.&nbsp; You could change the script so that it only puts the X marker on tokens that are on pages with active players, but I the events might still get to CombatMaster depending on what it's watching. Try this version:&nbsp; <a href="https://gist.github.com/shdwjk/ed46ee5f743502455c668936bfddc849" rel="nofollow">https://gist.github.com/shdwjk/ed46ee5f743502455c668936bfddc849</a>
Thank you both! Aaron, I tested that version and it doesn't apply the marker at all, even on the page with the player ribbon. I have it set up so PCs at or below 0 are given the Pummeled marker, in case that makes any difference.
Just getting ready to post the same thing..
1587245037
The Aaron
Roll20 Production Team
API Scripter
Hmm.. it seems like that should status marker code should never have worked since the Custom Token Markers updated.&nbsp; I updated the Gist a new version, try this?&nbsp; &nbsp; <a href="https://gist.github.com/shdwjk/ed46ee5f743502455c668936bfddc849" rel="nofollow">https://gist.github.com/shdwjk/ed46ee5f743502455c668936bfddc849</a>
That version seems to be doing just the trick! I've been using the one-click which I think is v0.1.6? But it was applying the markers just fine. I've seen people set it to use custom markers just by changing the default markers I'm the script. But that last version is at least applying markers to tokens on the player ribbon page, so thank you so much!
Not that it is a big deal but if you modify the token, not on the player page it still adds multiply in chat, but if it is on the ribbon page it works great.&nbsp; Once again nice job Aaron.
I hadn't thought to test that, Kilter, good catch! @The Aaron, sort of related: I've noticed some scripts interact differently with custom markers that are GM-uploaded vs. how they interact with ones bought in the Marketplace. For example, CombatMaster has had issues only related to bought markers. Have you noticed any weirdness that requires them to be treated differently in-script?
1587253234
The Aaron
Roll20 Production Team
API Scripter
The only weirdness should be if you were trying to make an Token using the URLs.&nbsp; They aren't uploaded via the standard pipeline, so they only work as TokenMarkers or in Chat.&nbsp; They won't work on Handouts, Characters, Tokens (the actual graphic), etc.
1587253295
The Aaron
Roll20 Production Team
API Scripter
Kilter said: Not that it is a big deal but if you modify the token, not on the player page it still adds multiply in chat, but if it is on the ribbon page it works great.&nbsp; Once again nice job Aaron. It's because I set it up to work on any page where there is a player, including players split from the party, or the GM.
1587305173

Edited 1587305210
Since you are already in there, And I know that Death Tracker monitors HP Changes, Would you be able to make an improvement while working on the script? The DM Toolkit has this neat little thing they do where they have the amount of damage or healing float a little number off the token when damage or healing is applied, if they use the API command to do it.&nbsp; Would you be able to do that, tieing it into the "Show Effects" for damage and healing as an automated function?&nbsp; In addition, as a function performable in a macro that applies the specified amount of healing or damage to the targeted token/ npc with the floaty text?&nbsp; For a Macro Example: !dead --heal ?{Amount of Healing} @{target|token_id} with green or gold floaty text and increases the health by the amount, up to maximum !dead --damage ?{Amount of Damage} @{target|token_id} with red or black floaty text and decreases the health by the amount, down to 0, but monitoring for massive damage. Just wondering if we could expand on the intention of the original API with some ability to adjust hp (allowing the PCs that joy) and have that adjustment show up dynamically.&nbsp; The only reason I see this as an option is because the API already monitors the HP bar and differences in HP amounts.&nbsp; I thought it could be an easy slide into existing functions.&nbsp; If not, no harm, no foul.
Wolf Thunderspirit said: In addition, as a function performable in a macro that applies the specified amount of healing or damage to the targeted token/ npc with the floaty text?&nbsp; <a href="https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers" rel="nofollow">https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers</a> Here is a script that may help you out with that.
Kilter said: Wolf Thunderspirit said: In addition, as a function performable in a macro that applies the specified amount of healing or damage to the targeted token/ npc with the floaty text?&nbsp; <a href="https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers" rel="nofollow">https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers</a> Here is a script that may help you out with that. I like that, it's got almost everything I'm looking for but the ability for players (and the DM) to apply damage and healing from command.&nbsp; Good call though - I might use it if TheAaron doesn't want to mod DT.
Here is a script that reads damage script (If you use the Roll20 5E sheet) or you can create/modify the macros in the last link as well. (Very useful macros, mostly with tokenMod) <a href="https://app.roll20.net/forum/post/7831600/listening-for-5e-ogl-damage-rolls" rel="nofollow">https://app.roll20.net/forum/post/7831600/listening-for-5e-ogl-damage-rolls</a> <a href="https://github.com/poltergeisha/Roll20-Like-A-Boss" rel="nofollow">https://github.com/poltergeisha/Roll20-Like-A-Boss</a> Just as a list of things already in place, that do what you are asking. As you said in case TheAaron doesn't want to Mod DT.
@Kilter that script for 5e damage rolls is really cool. I've been trying to adjust it to work with the official Pathfinder Second Edition sheet, but still can't get it to recognize when a damage roll is made... Anyone able to spot what I'm missing? I've got this so far extractRoll = function(msg){ return _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']=v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } findRollResult = function(msg, rollname, isString = 0){ let pattern = new RegExp('{{' + rollname + '=(.+?)}}'); let result = 0; if (isString &gt; 0) { msg.content.replace(pattern,(match,rollResult)=&gt;{ result = rollResult; }); } else { msg.content.replace(pattern,(match,rollResult)=&gt;{ result = parseInt(rollResult); }); } return result; } on("chat:message", function(orig_msg) { if (orig_msg.rolltemplate &amp;&amp; orig_msg.inlinerolls) { if(/{{dmg\d=/.test(orig_msg.content)){ let msg = _.clone(orig_msg), damageType, damageBase, damageCrit, atk1, atk2, critTarget, charName; damageBase = damageCrit = atk1 = atk2 = 0; damageType = charName = ''; msg.content = extractRoll(msg); msg.content.replace(/charname=(.+?)$/,(match,charname)=&gt;{ charName = charname; }); damageType = findRollResult(msg, 'roll02_info', 1); damageBase = findRollResult(msg, 'roll02') + findRollResult(msg, 'roll04'); damageCrit = damageBase * 2; if (damageType == 'Heal') { sendChat('', '!setattr --silent --name Damage Tracker --lastHeal|' + damageBase); sendChat('', '/w gm [Apply Healing](!&amp;#13;&amp;#37;{Damage Tracker|ApplyHeal}) | [Damage Undead](!&amp;#13;&amp;#37;{Damage Tracker|DamageUndead})'); } else { sendChat('', '!setattr --silent --name Damage Tracker --lastBaseDamage|' + damageBase); sendChat('', '!setattr --silent --name Damage Tracker --lastCritDamage|' + damageCrit); sendChat('', ' /w gm [Hit](!&amp;#13;&amp;#37;{Damage Tracker|ApplyDamage}) | [Critical](!&amp;#13;&amp;#37;{Damage Tracker|ApplyDamageWithCrit}) | [Other](!token-mod --ids @{target|token_id} --set bar1_value|?{Dmg Amount|0}) '); } } } }); And here's a sample macro: @{Shezukoatl|whispertype} &amp;{template:rolls} {{limit_height=@{Shezukoatl|roll_limit_height}}} {{charactername=@{Shezukoatl|character_name}}} {{header=Scythe—Rage}} {{subheader=^{melee_strike}}} {{notes_show=@{Shezukoatl|roll_show_notes}}} {{notes=**DEADLY:** [**+1d10**](`&amp;#47;r 1d10) dmg on crit}} {{roll01_name=^{attack}}} {{roll01=[[1d20cs20cf1 + [ ] 4[@{Shezukoatl|text_modifier}] + (@{Shezukoatl|query_roll_bonus})[@{Shezukoatl|text_bonus}]]]}} {{roll01_type=attack}} {{roll01_info=Deadly d10 | Trip}} {{roll01_critical=1}} {{roll02_name=^{damage}}} {{roll02=[[1D10 + 4[@{Shezukoatl|text_ability_modifier}] + 0[WEAPON SPECIALIZATION] + 0[TEMP] + 0[OTHER] + @{Shezukoatl|query_roll_damage_bonus}[@{Shezukoatl|text_roll_damage_bonus}]]]}} {{roll02_type=damage}} {{roll02_info=slashing}} {{roll04_name=^{damage_additional}}} {{roll04=[[2]] electricity, [[1d3]] fire}} {{roll04_type=damage}}
1587386864
The Aaron
Roll20 Production Team
API Scripter
This won't match anything in the sample input if(/{{dmg\d=/.test(orig_msg.content)){: That's preventing it from getting into the body.&nbsp; Something like: if(/{{roll\d+_type=damage/.test(orig_msg.content)){ should get you into the body.
1587388466

Edited 1587388662
@TheAaron - Thoughts? Kilter did mention one source for comparitives: <a href="https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers" rel="nofollow">https://app.roll20.net/forum/post/7347890/script-ff-style-damage-numbers</a> and I mentioned how the DM Tookit can apply healing and damage via API. If these were all combined to the health bar in one collective script, it would do wonders. But I also know it's a big ask.&nbsp; Unless you're tired of that minecraft thing you got going on yet ;-) lol Wolf Thunderspirit said: Since you are already in there, And I know that Death Tracker monitors HP Changes, Would you be able to make an improvement while working on the script? The DM Toolkit has this neat little thing they do where they have the amount of damage or healing float a little number off the token when damage or healing is applied, if they use the API command to do it.&nbsp; Would you be able to do that, tieing it into the "Show Effects" for damage and healing as an automated function?&nbsp; In addition, as a function performable in a macro that applies the specified amount of healing or damage to the targeted token/ npc with the floaty text?&nbsp; For a Macro Example: !dead --heal ?{Amount of Healing} @{target|token_id} with green or gold floaty text and increases the health by the amount, up to maximum !dead --damage ?{Amount of Damage} @{target|token_id} with red or black floaty text and decreases the health by the amount, down to 0, but monitoring for massive damage. Just wondering if we could expand on the intention of the original API with some ability to adjust hp (allowing the PCs that joy) and have that adjustment show up dynamically.&nbsp; The only reason I see this as an option is because the API already monitors the HP bar and differences in HP amounts.&nbsp; I thought it could be an easy slide into existing functions.&nbsp; If not, no harm, no foul.
1587388774
The Aaron
Roll20 Production Team
API Scripter
Oh, sorry, meant to respond to that. That's probably more than I'd want to change in someone else's script, particularly if there's already another one that will do it. If there's a reason the two don't work together, I could look into fixing that.&nbsp;
Kilter said: Here is a script that reads damage script (If you use the Roll20 5E sheet) or you can create/modify the macros in the last link as well. (Very useful macros, mostly with tokenMod) <a href="https://app.roll20.net/forum/post/7831600/listening-for-5e-ogl-damage-rolls" rel="nofollow">https://app.roll20.net/forum/post/7831600/listening-for-5e-ogl-damage-rolls</a> <a href="https://github.com/poltergeisha/Roll20-Like-A-Boss" rel="nofollow">https://github.com/poltergeisha/Roll20-Like-A-Boss</a> Just as a list of things already in place, that do what you are asking. As you said in case TheAaron doesn't want to Mod DT. Kilter - I only use the OGL Sheet in Other People's Games.&nbsp; I will always and forever, solidly, only ever use the Shaped Sheet in my own games.&nbsp; The OGL sheet is so one-note that it's the difference between Marinated and Grilled Steak &amp; Baked v. Unseasoned/ Unflavored Cornmeal Mush.&nbsp; If that made you wince, so does the OGL sheet in the same way for me.&nbsp; I use it IF FORCED TO.&nbsp; Otherwise I steer clear of it altogether and wish Roll20 would realize how inferior it is by comparison to the Shaped Sheet .... but I need to get off the soapbox... I still appreciate the help, none-the-less...
The Aaron said: Oh, sorry, meant to respond to that. That's probably more than I'd want to change in someone else's script, particularly if there's already another one that will do it. If there's a reason the two don't work together, I could look into fixing that.&nbsp; Is there a way to get just a damage and heal that players and dm's can use that kind of works with that other floaty text API and DT?&nbsp; I wanted them to be able to do this for their healing mostly, and so I could set macros up universally for HP pots, etc.&nbsp; The only one I could find, sadly only works with the OGL sheet.&nbsp; I wanted something that works with the Shaped sheet also.&nbsp; In other words, the cleric who casts cure wounds can actually put that healing on another player instead of having them do it, etc.&nbsp; Or the damage they do - which I wish there was a way to take resistance to damage types into account before applying.&nbsp; (We can set damage types - why do we never have an ability to use these damage types in an API/ Macro?)
1587392236

Edited 1587392247
The Aaron
Roll20 Production Team
API Scripter
Very likely.&nbsp; Let's start a new thread about it, be sure to link to that script. It should be as simple as adding an observer to it which observes TokenMod changes, and give the players macros for that.
The Aaron said: This won't match anything in the sample input if(/{{dmg\d=/.test(orig_msg.content)){: That's preventing it from getting into the body.&nbsp; Something like: if(/{{roll\d+_type=damage/.test(orig_msg.content)){ should get you into the body. Thanks for catching that, got it working!
The Aaron said: Very likely.&nbsp; Let's start a new thread about it, be sure to link to that script. It should be as simple as adding an observer to it which observes TokenMod changes, and give the players macros for that. Let me know what the new thread is then ...