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

AlterBars 2.0 - New and improved!

1488950856

Edited 1494507314
This simple API script allows you and your players to use a macro to adjust the value of the three bars of a token. The script has been updated to use a more aesthetically pleasing emote and eventually support triggering the FX and Aura changes from the Aura/Tint HealthColor written by DXWarlock. I have provided several macros below to highlight possible uses for this script and a list of the variables the GM can set within the script itself (some day I'll get a fancy chat menu and one click install). To Do List: Add chat menu for adjusting variables. Upgrade to a one-click install configuration. Figure out why FX animations aren't being triggered when changes to the token are sent to HealthColor. Make minor adjustments to left margin to center announcement properly. Add option to show red/green chat announcement per use instead of all the time off or on. Add option to color chat announcement using the Player Color instead of any other colors. Break out chat announcement css into a list of options DM can set, including background image. Add results of random rolls in the tooltip when mousing over the result in chat. Add logic to hide npc names if players would not normally be able to see them. March 21st, 2017 ~ 8:45 am eastern Version: 2.0.5 Link: <a href="https://gist.github.com/Sky-Captain-13/a503c359146" rel="nofollow">https://gist.github.com/Sky-Captain-13/a503c359146</a>... Bugfix: Added fix by TheAaron to catch token objects that might not be tokens. March 21st, 2017 ~ 8:45 am eastern Version: 2.0.4 Bugfix: Added logic to exit the script if there is no valid --target tag. Minor Update: &nbsp;Altered the hide function to the following --show|all will announce the results in chat --show|GM will whisper the results only to the GM --show|none will not show any message at all March 8th, 2017 ~ 6:45 pm eastern Version: 2.0.3 Bugfix: Corrected logic for verifying a valid Bar was designated by number or barkey. March 8th, 2017 ~ 6:20 am eastern Version: 2.0.2 Bugfix: Added a -7px left margin to the announcement CSS to properly center the box and text in the chat window. March 8th, 2017 ~ 2:25 am eastern Version: 2.0.1 Bugfix: &nbsp;FX Animations are now properly triggered by the Aura/Tint HealthColor script by DXWarlock. March 8th, 2017 ~ 12:00 am eastern Version: &nbsp;2.0.0 Initial Release: &nbsp;Please report any bugs you come across. Thanks! Variable Descriptions ALT_COLORS If set to true, AlterBars uses a dark green or dark red emote instead of the default orange color. PREVENT_OVERMAX If set to true, AlterBars will reset the bar's value to its maximum if it would be over that max value. STOP_AT_ZERO The opposite of prevent_overmax, this option will set a bar's value to zero if it would drop below that. ANNOUNCE_CHANGE Set to true to send a message to the chat window, showing which token gained or lost points and how much. ALTER_GM Change to true to send an alert to the GM instead of everyone. Bar Names & Designations A small upgrade to this script is the ability to provide the verb and singular and plural names of the bars. Formerly, the script simply used gained or loses, but now you can set these options per bar and whether it is a gain or a loss. The default settings assume Bar1 is being used for Hit Points (which is the default bar used for HP on tokens made for the built-in compendium for D&D 5e). Example: Paladin heals 5 hit points. var Bar1Gain = ["heals", "hit point", "hit points"]; var Bar1Loss = ["takes", "damage", "damage"]; var Bar2Gain = ["recovers", "mana", "mana"] var Bar2Loss = ["spends", "mana", "mana"] var Bar3Gain = ["heals", "hit point", "hit points"]; var Bar3Loss = ["takes", "damage", "damage"]; Sample Macros Drink a Potion of Healing !alter --target|@{selected|token_id} --bar|1 --amount|+2d4+2 Cast Cure Wounds on Ally !alter --target|@{target|token_id} --bar|1 --amount|+?{Cast at Level|1|2|3|4|5|6|7|8|9}d8 + @{CharacterName|wisdom_mod} Deal Damage to Enemy !alter --target|@{target|token_id} --bar|1 --amount|-?{Damage Dealt|0} Damage (Self) !alter --target|@{selected|token_id} --bar|1 --amount|-?{Damage Taken|0} Heal (Selected) !alter --target|@{selected|token_id} --bar|1 --amount|+?{Amount Healed|0} Heal (Target) !alter --target|@{target|token_id} --bar|1 --amount|+?{Amount Healed|0} Damage (Selected) !alter --target|@{selected|token_id} --bar|1 --amount|-?{Damage Taken|0} Damage (Target) !alter --target|@{target|token_id} --bar|1 --amount|-?{Damage Taken|0}
1488976496
The Aaron
Pro
API Scripter
var Previous = { &nbsp; "bar1_value": Target.get("bar1_value"), &nbsp; "bar2_value": Target.get("bar2_value"), &nbsp; "bar3_value": Target.get("bar3_value")&nbsp; }; could be replaced with: var Previous = JSON.parse(JSON.stringify(Target)); to perfectly duplicate what gets passed in events as prev.
Of course it can be done in one line... silly me for thinking my solution was easy and simple, lol. Thanks. Made the change to futureproof the script, just in case someone down the line needs more info from the previous object.
1488981165
The Aaron
Pro
API Scripter
HAHAHAHA, well, you could write it as var Previous = JSON.parse( JSON.stringify( Target ) ); to get the line count up. =D
1489006532

Edited 1489007300
Looks great SkyCap! Am I miss reading your notes? The Health Aura script doesn't seem to be updating after using alterbars to change a targets health.
Dustin C. said: Looks great SkyCap! I anxiously waiting the support for Aura health, Love the simplicity of your Alterbars but im torn over the fun Blood spurts from the Arua mod lol :)&nbsp; It's already in. I got that fixed this morning.
I'm getting an error from this. I copied your macro, changing it to bar 3, and it throws the error "(From ERROR): (DM) That is not a valid bar."
AH-HA... found my issue... DX updated yesterday (3/7/17) and I had an older version. Now it's working! Awesome job! Just FYI version 1.3.1 did the trick :)
1489007792

Edited 1489008678
Josh said: I'm getting an error from this. I copied your macro, changing it to bar 3, and it throws the error "(From ERROR): (DM) That is not a valid bar." I will look at this when I get a chance. Leaving for work soon. -edit- I have an idea where the error is happening, but don't have time to fix it before work. Will try and look at it at work, but can't promise anything.
March 8th, 2017 ~ 6:45 pm eastern Version: 2.0.3 Link: <a href="https://gist.github.com/Sky-Captain-13/a503c359146" rel="nofollow">https://gist.github.com/Sky-Captain-13/a503c359146</a>... Bugfix: Corrected logic for verifying a valid Bar was designated by number or barkey.
Aaron, if you see this... would you happen to know why the 3D dice aren't rolling automatically? // Main process... sendChat("", "/r " + AlterValue, function (outs) { AlterValue = parseInt(JSON.parse(outs[0].content).total); var Tooltip = "Rolling " + Expression + " = " + AlterValue + "' class='a inlinerollresult showtip tipsy-n'"; if (Operand1 != "-") { // Add to bar... if (PREVENT_OVERMAX) AlterValue = (AlterValue + CurrentValue &gt; MaxValue) ? MaxValue - CurrentValue : AlterValue; if (ANNOUNCE_CHANGE) sendChat("", "/desc &lt;div style='" + AlertGainStyle + "'&gt;" + Target.get("name") + " " + BarGain[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarGain[1] : BarGain[2]) + "." + "&lt;/div&gt;"); if (ALERT_GM || NoAnnounce) sendChat(who, "/w GM &lt;div style='" + AlertGainStyle + "'&gt;" + Target.get("name") + " " + BarGain[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarGain[1] : BarGain[2]) + "." + "&lt;/div&gt;"); Target.set("bar" + Bar + "_value", CurrentValue += AlterValue); } else { // Subtract from bar... if (STOP_AT_ZERO && (CurrentValue - AlterValue &lt; 0)) AlterValue = CurrentValue; if (ANNOUNCE_CHANGE && !NoAnnounce) sendChat("", "/desc &lt;div style='" + AlertLossStyle + "'&gt;" + Target.get("name") + " " + BarLoss[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarLoss[1] : BarLoss[2]) + "." + "&lt;/div&gt;"); if (ALERT_GM || NoAnnounce) sendChat(who, "/w GM &lt;div style='" + AlertLossStyle + "'&gt;" + Target.get("name") + " " + BarLoss[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarLoss[1] : BarLoss[2]) + "." + "&lt;/div&gt;"); Target.set("bar" + Bar + "_value", CurrentValue -= AlterValue); } if ('undefined' !== typeof HealthColors && HealthColors.Update) HealthColors.Update(Target, Previous); }, {use3d: true})
Can this be used to 'heal' or 'damage' multiple tokens at once?
eastwood said: Can this be used to 'heal' or 'damage' multiple tokens at once? Currently no. &nbsp;That would require some re-writing of the script, but might be something much easier done once the new jsnode update is pushed from the dev server to the production servers.
SkyCaptainXIII said: Currently no. &nbsp;That would require some re-writing of the script, but might be something much easier done once the new jsnode update is pushed from the dev server to the production servers. Roger that! Still a great script, thanks!
Love this, and seconding the ask for the ability to damage / heal multiple tokens. Groupcheck + AlterBars = dead easy AoEs :)
Thorsten B. said: Love this, and seconding the ask for the ability to damage / heal multiple tokens. Groupcheck + AlterBars = dead easy AoEs :) Not sure how it will interact with GroupCheck...
SkyCaptainXIII said: Not sure how it will interact with GroupCheck... Manually :). GroupCheck reduces saving throws from N to 1 click. AlterBars could then reduce HP adjustment to a few clicks, depending on how many NPCs did or did not make their saving throw.&nbsp; It's not that GroupCheck and AlterBars interact, it's that both take a separate part of resolving an AoE attack and simplify it.
1489518098

Edited 1489518757
Jakob
Sheet Author
API Scripter
Thorsten B. said: SkyCaptainXIII said: Not sure how it will interact with GroupCheck... Manually :). GroupCheck reduces saving throws from N to 1 click. AlterBars could then reduce HP adjustment to a few clicks, depending on how many NPCs did or did not make their saving throw.&nbsp; It's not that GroupCheck and AlterBars interact, it's that both take a separate part of resolving an AoE attack and simplify it. Not to hijack the thread, but if you look in the GroupCheck thread, you'll find a small ApplyDamage script I wrote just for this purpose (assuming you do not already know about it). It doesn't have a fancy output like AlterBars (nor is it very user-friendly unless used in a macro together with GroupCheck), but it's specifically adapted to interact with GroupCheck in a semi-automated way (i.e. apply full/half/no damage with one button click). With some changes, among them multiple targets, you could plug in AlterBars instead.
1490051533
Alicia
Sheet Author
Glad to see you're back. Couple things. Is it possible to throw in some error handling for when you don't have the tags in correctly.. I had to restart the API multiple times because it didn't like I didn't have "--" in there for one of the macros.&nbsp; Also, before you could put 'hide' at the end of the string to have the alerts go to GM only. What's the equivalent now? Thanks for the update to include Aura/Health. I'm working on changing things over to work with the new updates and it's a relief to have support.
1490054801
The Aaron
Pro
API Scripter
SkyCaptainXIII said: Aaron, if you see this... would you happen to know why the 3D dice aren't rolling automatically? // Main process... sendChat("", "/r " + AlterValue, function (outs) { AlterValue = parseInt(JSON.parse(outs[0].content).total); var Tooltip = "Rolling " + Expression + " = " + AlterValue + "' class='a inlinerollresult showtip tipsy-n'"; if (Operand1 != "-") { // Add to bar... if (PREVENT_OVERMAX) AlterValue = (AlterValue + CurrentValue &gt; MaxValue) ? MaxValue - CurrentValue : AlterValue; if (ANNOUNCE_CHANGE) sendChat("", "/desc &lt;div style='" + AlertGainStyle + "'&gt;" + Target.get("name") + " " + BarGain[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarGain[1] : BarGain[2]) + "." + "&lt;/div&gt;"); if (ALERT_GM || NoAnnounce) sendChat(who, "/w GM &lt;div style='" + AlertGainStyle + "'&gt;" + Target.get("name") + " " + BarGain[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarGain[1] : BarGain[2]) + "." + "&lt;/div&gt;"); Target.set("bar" + Bar + "_value", CurrentValue += AlterValue); } else { // Subtract from bar... if (STOP_AT_ZERO && (CurrentValue - AlterValue &lt; 0)) AlterValue = CurrentValue; if (ANNOUNCE_CHANGE && !NoAnnounce) sendChat("", "/desc &lt;div style='" + AlertLossStyle + "'&gt;" + Target.get("name") + " " + BarLoss[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarLoss[1] : BarLoss[2]) + "." + "&lt;/div&gt;"); if (ALERT_GM || NoAnnounce) sendChat(who, "/w GM &lt;div style='" + AlertLossStyle + "'&gt;" + Target.get("name") + " " + BarLoss[0] + " &lt;span title='" + Tooltip + "'&gt;" + AlterValue + "&lt;/span&gt; " + ((AlterValue == 1) ? BarLoss[1] : BarLoss[2]) + "." + "&lt;/div&gt;"); Target.set("bar" + Bar + "_value", CurrentValue -= AlterValue); } if ('undefined' !== typeof HealthColors && HealthColors.Update) HealthColors.Update(Target, Previous); }, {use3d: true}) Just saw this... My guess would be because the roll is intercepted by the API through the callback function, so it never gets sent to the Chat to get turned into 3d dice. &nbsp;I've never actually used the use3d: setting beyond a "yep, that works" script when it first was released.&nbsp;
1490075414

Edited 1490077008
Alicia G said: Glad to see you're back. Couple things. Is it possible to throw in some error handling for when you don't have the tags in correctly.. I had to restart the API multiple times because it didn't like I didn't have "--" in there for one of the macros.&nbsp; Also, before you could put 'hide' at the end of the string to have the alerts go to GM only. What's the equivalent now? Thanks for the update to include Aura/Health. I'm working on changing things over to work with the new updates and it's a relief to have support. I'll work on this today. However, one of the things you want is already in there: --hide|true &nbsp;I should probably do a little more work on that and use a better name and different options... &nbsp;how about: --show|all (default if missing) --show|gm --show|none
March 21st, 2017 ~ 8:45 am eastern Version: 2.0.4 Link: <a href="https://gist.github.com/Sky-Captain-13/a503c359146" rel="nofollow">https://gist.github.com/Sky-Captain-13/a503c359146</a>... Bugfix: Added logic to exit the script if there is no valid --target tag. Minor Update: Altered the hide function to the following... --show|all will announce the results in chat --show|GM will whisper the results only to the GM --show|none will not show any message at all
1490108991
Alicia
Sheet Author
Awesome thanks. I'll test when I get home.
I really like AlterBar, but my players didn't. It would really be nice to be able to use AlterBar as an attack resolves. I tried adding the macro to an attack on 5e-Shaped but it asks for the info before you even do anything. I would like to have the attack resolve and then have the players alterbars without clicking a separate macro. I know they could get used to using a separate macro but they didn't seem happy with it when I tried using this API in my last session. Is there anyway to do this?
1490112053
Alicia
Sheet Author
Jerry F. said: I really like AlterBar, but my players didn't. It would really be nice to be able to use AlterBar as an attack resolves. I tried adding the macro to an attack on 5e-Shaped but it asks for the info before you even do anything. I would like to have the attack resolve and then have the players alterbars without clicking a separate macro. I know they could get used to using a separate macro but they didn't seem happy with it when I tried using this API in my last session. Is there anyway to do this? I know every group is different but I just manage it myself as a GM. Use as a decice to indicate their attack is done and final.
Alicia G said: Jerry F. said: I really like AlterBar, but my players didn't. It would really be nice to be able to use AlterBar as an attack resolves. I tried adding the macro to an attack on 5e-Shaped but it asks for the info before you even do anything. I would like to have the attack resolve and then have the players alterbars without clicking a separate macro. I know they could get used to using a separate macro but they didn't seem happy with it when I tried using this API in my last session. Is there anyway to do this? I know every group is different but I just manage it myself as a GM. Use as a decice to indicate their attack is done and final. I think I like where you are coming from.
Jerry F. said: I really like AlterBar, but my players didn't. It would really be nice to be able to use AlterBar as an attack resolves. I tried adding the macro to an attack on 5e-Shaped but it asks for the info before you even do anything. I would like to have the attack resolve and then have the players alterbars without clicking a separate macro. I know they could get used to using a separate macro but they didn't seem happy with it when I tried using this API in my last session. Is there anyway to do this? You can now... if you use powercards. But I don't see powercards being as popular these days due to the ease of making macros/attacks from character sheets.
SkyCaptainXIII said: Jerry F. said: I really like AlterBar, but my players didn't. It would really be nice to be able to use AlterBar as an attack resolves. I tried adding the macro to an attack on 5e-Shaped but it asks for the info before you even do anything. I would like to have the attack resolve and then have the players alterbars without clicking a separate macro. I know they could get used to using a separate macro but they didn't seem happy with it when I tried using this API in my last session. Is there anyway to do this? You can now... if you use powercards. But I don't see powercards being as popular these days due to the ease of making macros/attacks from character sheets. Powercards are marvelous. :)
You know I just added the macro for the AlterBar as an attacher and I think it will work great.
Jerry F. said: You know I just added the macro for the AlterBar as an attacher and I think it will work great. Only issue is that the macro has to resolve first before anything is sent to chat, so players won't see the damage until after its done.
I did it as a clickable.
Ah, nice.
March 21st, 2017 ~ 8:45 am eastern Version: 2.0.5 Link: <a href="https://gist.github.com/Sky-Captain-13/a503c359146" rel="nofollow">https://gist.github.com/Sky-Captain-13/a503c359146</a>... Bugfix: Added fix by TheAaron to catch token objects that might not be tokens.
I am using this script in my Vampire game and when I use the macro it always says "NPC spends xxxx" whatever it is. Is there a way to alter the script to show character name?
The token needs to have it set so that the name is visible to players.
Sky said: The token needs to have it set so that the name is visible to players. Thanks that worked
It'd be very nice if this can be included and work in the Shaped Sheet's freeform. But right now it asks the alter bars change before the actual roll comes out.&nbsp; Example: Click Cure Wounds &gt; Should know how much it heals &gt; then enter the number healed to change the bar of target. Other than that, this looks very promising, look forward to updates :)
Mal said: It'd be very nice if this can be included and work in the Shaped Sheet's freeform. But right now it asks the alter bars change before the actual roll comes out.&nbsp; Example: Click Cure Wounds &gt; Should know how much it heals &gt; then enter the number healed to change the bar of target. Other than that, this looks very promising, look forward to updates :) That's because of how macros work, period. Regardless of the sheet. Anytime you hit the button on a macro, it has to go through and fill out every query before it sends anything to chat.
Mal said: It'd be very nice if this can be included and work in the Shaped Sheet's freeform. But right now it asks the alter bars change before the actual roll comes out.&nbsp; Example: Click Cure Wounds &gt; Should know how much it heals &gt; then enter the number healed to change the bar of target. Other than that, this looks very promising, look forward to updates :) I just created a button using attacher and then once the roll has happened then the player can click that to apply it. Though I also reference my macro sheet I created for moving around from game to game.
I am trying to setup some macros with a set character without having to select them. How would I do that?
Get the token's id and replace @{target/selected|token_id} with that id.
1497662493

Edited 1497662598
It would look like... !alter --target| -KmncoclSF8BpARGzeeW --bar|1 --amount|+?{HP Gained|0} ...instead of... !alter --target| @{target||token_id} --bar|1 --amount|+?{HP Gained|0} ... but obviously you would need to get each token's individual id. Token ID's change from map to map though. So you it's not really something you can do.
Sky said: It would look like... !alter --target| -KmncoclSF8BpARGzeeW --bar|1 --amount|+?{HP Gained|0} ...instead of... !alter --target| @{target||token_id} --bar|1 --amount|+?{HP Gained|0} ... but obviously you would need to get each token's individual id. Token ID's change from map to map though. So you it's not really something you can do. They change map to map?&nbsp; So its not like character_id which is per game?
Each and every token has its own unique id. Even on the same map.
Sky said: Each and every token has its own unique id. Even on the same map. Thanks for the headsup
Hey great script, thank you for that. Does someone has an idea why I get this: if I try one of the examples at the beginning (this one for example:!alter --target|@{selected|token_id} --bar|1 --amount|+?{Amount Healed|0})? Thank you&nbsp;
Dunno... it should work.
My fault, outdated version of alterbar.... &nbsp;: )
1504287137

Edited 1504287197
I guess I should post this here instead of the PowerCards thread. Found a bug in the script. If a token_id has an underscore in it (see attached picture) the alterbars will throw an error when attempting to apply damage. Any possibility of a fix for it?
Copy and paste the old token/character. Token ID's are unique per token even if they're for the same character sheet.
Not sure what is wrong here please help if you can. !alter --target|@{target|token_id} --bar|1 --amount|+?{What type of potion|Healing, 2d4+2|Greater, 4d4+4 |Superior, 8d4+4 |Supreme, 10d4+20 |Full, +100} If I have the macro window open and test I get but if i click the macro for the tokens bar I get