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

Changing Token Appearance based on Token Bar value

Hey all, total newbie here. I'm fiddling around with TokenMod and roll table tokens to set up some appearance changes for my player characters. I've got a specific 'bloodied' appearance for the token that I'd like to flip the PC token to once they drop below 50% HP. How would I set it up to flip over automatically? I know there’s things like DeathTracker and the deprecated Bloodied and Downed script, but those apply statuses. How would I go about making it change token side instead?
Hey bigmaks, This could be done with the ScriptCards Mod, specifically  ScriptCards Triggers If you are interested in using ScriptCards for this, let me know and I can probably help out with this. Essentially you would install ScriptCards, create a character named ScriptCards_Triggers on a non-Beacon character sheet, create an ability named change:graphic  and have a ScriptCard in that ability that checks if the HP bar is below a value and then change the side of the token. I am sure there are other ways to do it as well but I know ScriptCards can do this.
1758643912
timmaugh
Forum Champion
API Scripter
Hey, bigmaks... you can generate the TokenMod help handout with the line: !token-mod --help That will create a handout that you can search (I like to pop it out of the game and do a CTRL+F to find what I'm looking for). Specific to your request, the command you're looking for is something like: !token-mod --set currentside|2 ...where the sides are indexed (as far as TokenMod is concerned) starting at 1. So if you had 2 images for each token (one for >50% damage, the other for <50% damage), then the above command is exactly what you'd need. If you had 4 images (for 25% ranges of remaining hits), then having hits between 25% and 50% might be the third image, so your command line would become: !token-mod --set currentside|3 If you also added the MetascriptToolbox, you could augment this with a conditional check of what the remaining hits were, then choose to apply the correct side based on the result. I can provide an example if you let us know how you derive the percentage of hits remaining (numbers in bars? or attributes? if attributes, what sheet?)
Joshua N. said: Hey bigmaks, This could be done with the ScriptCards Mod, specifically  ScriptCards Triggers If you are interested in using ScriptCards for this, let me know and I can probably help out with this. Essentially you would install ScriptCards, create a character named ScriptCards_Triggers on a non-Beacon character sheet, create an ability named change:graphic  and have a ScriptCard in that ability that checks if the HP bar is below a value and then change the side of the token. I am sure there are other ways to do it as well but I know ScriptCards can do this. Hey! This is freakin rad.  I've got a character set up with the proper name, how would I go about setting up the ability?
Ok so once you have ScriptCards installed and running and you've made a character named ScriptCards_Triggers, you might need to restart your sandbox to pick up the trigger character. It should look something like this in the Mod Console: where it says "ScriptCards Triggers Active. Trigger Character ID is -SOMETHING Then on your ScriptCards_Trigger character on the attributes and abilities tab, make an ability named change:graphic  and copy the following code: !script {{ --/|CONFIGURATION VARIABLES --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1 --/|TRIGGER_REPLACEMENTS --#hidecard|1 --/|If the hp bar original value matches the new value, then hp did not change and jump to the end --?"[&GraphicOldbar[&HPBar]_value]" -eq "[&GraphicNewbar[&HPBar]_value]"|Done --/|If the current hp is 0 or lower, then do not apply bloodied --?"[&GraphicNewbar[&HPBar]_value]" -le 0|Done --=HPPercentage|[&GraphicNewbar[&HPBar]_value] / [&GraphicNewbar[&HPBar]_max] --?[$HPPercentage.Total] -lt 0.5|>ChangeSide;[&BloodiedSide]|>ChangeSide;[&HealthySide] --:Done| --X| --:ChangeSide|NumberOfSide --!t:[&GraphicNew_id]|currentSide:[%1%] --<| }} Should look something like this depending on the character sheet in your game: And change the configuration variables at the start. In my test game, the HP bar is bar 1 but change that if you use a different bar in your games.     --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1 And in Roll20 the sides start at 0. So 0 is the first side and goes up by 1. So in the above example the bloodied side is actually side 3 and the healthy side is side 2. Change that to match the sides. So the above will trigger every time a graphic is changed so we first check if the HPBar value is changed. If the HP didn't change, it skips to the end of the ScriptCard. If the HP changed but the HP is 0 or less, then skip to the end without changing the pic. So now we know if we are after that, that the HP changed and is above 0, so we calculate the percentage and change the pic accordingly to healthy if it's 50% or more, or bloodied side if lower than 50%. Let me know if you have any questions.
Joshua N. said: Ok so once you have ScriptCards installed and running and you've made a character named ScriptCards_Triggers, you might need to restart your sandbox to pick up the trigger character. It should look something like this in the Mod Console: where it says "ScriptCards Triggers Active. Trigger Character ID is -SOMETHING Then on your ScriptCards_Trigger character on the attributes and abilities tab, make an ability named change:graphic  and copy the following code: !script {{ --/|CONFIGURATION VARIABLES --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1 --/|TRIGGER_REPLACEMENTS --#hidecard|1 --/|If the hp bar original value matches the new value, then hp did not change and jump to the end --?"[&GraphicOldbar[&HPBar]_value]" -eq "[&GraphicNewbar[&HPBar]_value]"|Done --/|If the current hp is 0 or lower, then do not apply bloodied --?"[&GraphicNewbar[&HPBar]_value]" -le 0|Done --=HPPercentage|[&GraphicNewbar[&HPBar]_value] / [&GraphicNewbar[&HPBar]_max] --?[$HPPercentage.Total] -lt 0.5|>ChangeSide;[&BloodiedSide]|>ChangeSide;[&HealthySide] --:Done| --X| --:ChangeSide|NumberOfSide --!t:[&GraphicNew_id]|currentSide:[%1%] --<| }} Should look something like this depending on the character sheet in your game: And change the configuration variables at the start. In my test game, the HP bar is bar 1 but change that if you use a different bar in your games.     --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1 And in Roll20 the sides start at 0. So 0 is the first side and goes up by 1. So in the above example the bloodied side is actually side 3 and the healthy side is side 2. Change that to match the sides. So the above will trigger every time a graphic is changed so we first check if the HPBar value is changed. If the HP didn't change, it skips to the end of the ScriptCard. If the HP changed but the HP is 0 or less, then skip to the end without changing the pic. So now we know if we are after that, that the HP changed and is above 0, so we calculate the percentage and change the pic accordingly to healthy if it's 50% or more, or bloodied side if lower than 50%. Let me know if you have any questions. This works PERFECTLY! I would assume that all you have to do is add a third variable for --&DownedSide|3, then adjust it so if percentage is 0, it would apply downed side? Like: !script {{ --/|CONFIGURATION VARIABLES --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1     --&DownedSide|3 --/|TRIGGER_REPLACEMENTS --#hidecard|1 --/|If the hp bar original value matches the new value, then hp did not change and jump to the end --?"[&GraphicOldbar[&HPBar]_value]" -eq "[&GraphicNewbar[&HPBar]_value]"|Done --/|If the current hp is 0 or lower, then do not apply bloodied --?"[&GraphicNewbar[&HPBar]_value]" -le 0|Done --=HPPercentage|[&GraphicNewbar[&HPBar]_value] / [&GraphicNewbar[&HPBar]_max] --?[$HPPercentage.Total] -lt 0.5|>ChangeSide;[&BloodiedSide]|>ChangeSide;[&HealthySide]     --?[$HPPercentage.Total] -lt 0|>ChangeSide;[&DownedSide]|>ChangeSide;[&HealthySide] --:Done| --X| --:ChangeSide|NumberOfSide --!t:[&GraphicNew_id]|currentSide:[%1%] --<| }} Or is it not that simple, hah
That's pretty close. You would also need to change the condition above that section that skips if the HP is 0 or less. So something like this would work !script {{ --/|CONFIGURATION VARIABLES --&HPBar|1 --&BloodiedSide|2 --&HealthySide|1     --&DownedSide|3 --/|TRIGGER_REPLACEMENTS --#hidecard|1 --/|If the hp bar original value matches the new value, then hp did not change and jump to the end --?"[&GraphicOldbar[&HPBar]_value]" -eq "[&GraphicNewbar[&HPBar]_value]"|Done --/|If the current hp is 0 or lower, then change to Downed --?"[&GraphicNewbar[&HPBar]_value]" -le 0|>ChangeSide;[&DownedSide] --=HPPercentage|[&GraphicNewbar[&HPBar]_value] / [&GraphicNewbar[&HPBar]_max] --?[$HPPercentage.Total] -lt 0.5|>ChangeSide;[&BloodiedSide]|>ChangeSide;[&HealthySide] --:Done| --X| --:ChangeSide|NumberOfSide --!t:[&GraphicNew_id]|currentSide:[%1%] --^Done| }} That should work where it will check if the HP value is what changed and skip to the end if the HP was not what changed about the graphic. Then if the HP value is 0 or less, then change to Downed. If the HP is above 0, then it will calculate the percentage and change to either Healthy or Bloodied depending. Hope that works for you. If you want to get more into ScriptCards, I linked the wiki above so that's a good place. The wiki also has a Discord by the creator, Kurt. And there are a few tutorials that can hopefully teach some of the syntax and language features  link here Let me know if you have any questions about it.