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] Aura/Tint HealthColor

1435831712

Edited 1486931679
DXWarlock
Sheet Author
API Scripter
Thanks goes to The Aaron to pointing me in the direction to convert hex to hsl/hsv. He is an unending well of patience to help people.) [Script] Aura/Tint HealthColor GIT: <a href="https://gist.github.com/dxwarlock/5b38ea722a71e3d1b3d133deb5adbc79" rel="nofollow">https://gist.github.com/dxwarlock/5b38ea722a71e3d1b3d133deb5adbc79</a> ----------------- UPDATE: After a long time away, I am back and trying to work out some of the 'kinks' people pointed out. Let me know if I missed any. Changelog: 0.9.41: If you update you will need to reset your settings. Its not a lot of work, but with the way I reassigned the namespace it will not know the old settings. Added option to toggle for 'one off' tokens. This is for tokens not linked to a character sheet. Use this option with caution. With it on it will not know what is a character and what is not. It will attempt to HealthColor ANY token with stats in the bar you choose to use. Good to use if you use a lot of one off mook/NPC tokens. Fixed odd sized auras on non ribbon pages : Was an issue where tokens set on any page other than the players was on, it was using the scale of the player ribbon page. Now it bases it off the scale of the page the token is on, not the players. Fixed namespace and resetting settings on reload (thanks @&nbsp; DarKDinDoN ) Fixed PCset vs NPCset coding (Thanks @&nbsp; Kirsty ) ------------ Commands: !aura Brings up a menu with toggle buttons: Script abilities: Global on and off setting. Set which bar is the one to track for the color representation of health. Show player/NPC tokens health by a gradient of red/yellow/green as aura or tint color. Set a percentage that this aura kicks in at. (so players wont know until X% how hurt something is) Show red 'X' on dead of NPC/PC. Play Sound on dead of NPC/PC.&nbsp; ( To use the death sound, just set it from 'none' to whatever the exact name of your death sound is in the jukebox, right now has to be a single word name). Set if GM can see NPC names. Set if GM can see PC names. Set if Players see NPC names. Set if Players see other Players names. Set aura size. ------------ This scripts relies on PC and NPC tokens to have a corresponding character sheet they are tied to as "represents" and that token assigned to the sheet, so it can differentiate between whats a mob/player and a random environment token. ----------------- This script sets the aura or tint of mobs and players to a gradient between green/yellow/orange/red based on how hurt they are. It will work on any amount of HP as it takes the max and the current. figures out the percentage left, and set the hue to the correct color..100% is green, 0 is red. other percentages are a hue based on that percentage. For example in my campaign, players cannot see enemy health bars, OR other players only their own. This lets them tell how badly hurt someone/something is without the age old tabletop "how badly hurt does it look" 20 times during an encounter. NON-PCs :It sets any mob/creature not assigned to anyone, and has a min/max on a bar to have an aura based on its damage taken vs total health as the larger outside aura, and the smaller inside to white (to help see it on some backgrounds and give it a sort of 'token base' effect). PCs: Same as above but&nbsp;inside ring set to their roll20/dice color. Here is an example image of various Ogres in different states of damage. Along with the players all at full health. The only 'issue' is since the auras are semi transparent, the health color alters the player color inside ring to a different color as they blend, no way around this I believe. What Players see: (What GM sees:) There is possibly some setup some GM or players use of players/NPC/PC/tokens with the bars/assigned to/controlledby that will have a weird side effect or throw errors in log that I haven't accounted for, if you have any issues let me know Ill try to account for it if I can.
1435894506
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
This is a very good idea!
1435895472
The Aaron
Pro
API Scripter
Looks awesome!
Really like this script! I had nearly given up trying to hide monster health and just set bar1 to be viewable, but this is vastly preferable! On question: but would it be possible to use the token's tint instead of the aura? The reason is I tend to use "square" tokens and can only see a sliver of the aura color peeking out around the edges for them (I know I could just adjust the aura radius, but I would also like to be able to use my auras for other things).
1435952602
DXWarlock
Sheet Author
API Scripter
Sure, that would be no problem give me a little bit Ill update the first post with an option to use aura or tint.
1435953132

Edited 1435953313
DXWarlock
Sheet Author
API Scripter
There you go, just change var tint = false , to true and it will set the tint of the token instead. I guess I should get around to doing the fancy chat clickable toggle buttons like The Aaron does for options, but I got to figure out how to do that first :)
Wow that was fast! Just tested it out, works like a charm. Thanks!
1435954074
Ziechael
Forum Champion
Sheet Author
API Scripter
The only thing stopping me using this was the fact that i use auras for a lot of other things... with that tint option i'm sold and can't wait to give this a trial run :) Love the innovation!
Just had another thought -- would it be possible to implement a chat command to toggle the aura on/off either globally or for a selected token?
1435954854

Edited 1435955129
DXWarlock
Sheet Author
API Scripter
Probably, why i saying I'm going to dig thru The Aarons stuff and see how hes doing the chat buttons you can click when you do the command. Im bad about coding for 'us' and not making many options other than what I think of as we need it for our game. :) Once I figure out how hes doing it, I suppose I could create an attribute like "Health_toggle" on the character (since it only works on tokens with a sheet) that it reads to see if it should always ignore the tint when you drag it over. edit:wait that wont work, as you cannot toggle it until you drag it once to select it, so it would be tinted. Once you toggle it it wouldn't do it anymore, but the first one would be. you'd have to drag, toggle, and then delete and redrag the first time..that would get annoying. I'll have to figure out a way to make it know on things it hasn't seen on the table before..hmm Or do you mean on a case by case basis? Like only this token this time needs no aura, or a global "never set this PC/NPC to have one". Not sure if I can get to it today, but Ill figure it out before the weekend for sure if I can think of a resonable way to do it.
I guess I'm just looking for any way to suppress or enable the auras (or tint, in my case) in game with a command. For example, some friendly NPC tokens have health bars, and I'd rather not have them with the auras on until combat breaks out. I imagine it would be easier to do this globally for all tokens, something like: !life-auras --off No rush though! This is a nifty little script as is!
1435956058
Ziechael
Forum Champion
Sheet Author
API Scripter
Loving this latest addition... for some reason it isn't doing anything on my NPC's (they have no-one set as controlling but some are in players journals.. does that matter?) If possible, may i suggest another feature too... could you have a variable to toggle the tinting/auras based on a percentage of health remaining rather than all of the time? Fine for auras but tinting means that tokens are green whenever healthy which is fine but my players are vain and will only want to be alerted when they are below, say, 50% health etc?
1435956542

Edited 1435958129
DXWarlock
Sheet Author
API Scripter
Glenn said: I guess I'm just looking for any way to suppress or enable the auras (or tint, in my case) in game with a command. For example, some friendly NPC tokens have health bars, and I'd rather not have them with the auras on until combat breaks out. I imagine it would be easier to do this globally for all tokens, something like: !life-auras --off No rush though! This is a nifty little script as is! Hmm would checking to see if they have a visible bar work? since its redundant, if the players can see the bar itself no reason to have a tint (unless you just want it on them). Or like Zeichael was suggesting, if I do a percentage option for when they kick on, you could set it so unless they are hurt it wont show up. Like set it to 99%. no auras until someone hit them, then they kick in. And a global toggle I can do. Ziechael said: Loving this latest addition... for some reason it isn't doing anything on my NPC's (they have no-one set as controlling but some are in players journals.. does that matter?) If possible, may i suggest another feature too... could you have a variable to toggle the tinting/auras based on a percentage of health remaining rather than all of the time? Fine for auras but tinting means that tokens are green whenever healthy which is fine but my players are vain and will only want to be alerted when they are below, say, 50% health etc? It shouldn't matter, it checks to see if it represents a character sheet. And if someone has control of it its a PC, or if not its an NPC. Do you have any tokens for NPC's that arent tied to a sheet as the 'token' on that sheet? And adding the % wouldn't be too difficult, just a 'less than' before it triggers.
1435966305
DXWarlock
Sheet Author
API Scripter
Updated to 0.2, not totally finished but the rough idea of most the suggestions are there. Ill work on it some more tomorrow and sunday to try to finish fleshing it out.
1435997317

Edited 1435997574
Ziechael
Forum Champion
Sheet Author
API Scripter
William R. said: Ziechael said: Loving this latest addition... for some reason it isn't doing anything on my NPC's (they have no-one set as controlling but some are in players journals.. does that matter?) It shouldn't matter, it checks to see if it represents a character sheet. And if someone has control of it its a PC, or if not its an NPC. Do you have any tokens for NPC's that arent tied to a sheet as the 'token' on that sheet? And adding the % wouldn't be too difficult, just a 'less than' before it triggers. Awesome, can't wait to have time to properly test it. The NPC was definitely the token on the sheet etc but i'll spend some more time playing around with it when i can (at first nothing worked till i realised that having a character controlled by 'ALL PLAYERS' didn't seem to trigger the script and that it had to be tied to specific players to work?) edit: quick check and it turns out my NPC was tied to the sheet but not representing the sheet as you suspected (D'OH!)... the danger of using a test environment is that i'm not always as rigorous in my setup as i should be lol. The percentage thing would be awesome so thanks for taking that into consideration... my alternative was to hack your script to apply a transparent tint for the first couple of colour stages ;)
1435998089

Edited 1435998396
DXWarlock
Sheet Author
API Scripter
All players doesn't trigger it at the moment, but can certainly add a toggle for it. I was trying to take into consideration people that use a wagon/car/whatever as a 'group map' token all players can move around. I didn't want to overwrite any aura or tint they use for it. I was going off the assumption any token with one player controlling it was a PC, and no one controlling it was an NPC. For example the horse wagon they use for group location on world map that all player can move isnt affected, and when they are lost on the world map telling them "you assume you are somewhere in this area" with the aura as the radius they THINK they are in. If you need it I can add a toggle to set it to NPC(or an generic color) if all players can move it. And percentage is added to the newest update I posted in the first topic. heopfully I can get it as a easy question chat toggle by the end of the weekend. For the other things, have to be patient with me as I adjust to "I never thought of using a token that way" for suggestions that I didn't account for as I tend to do the lazy way of hard coding things to what our group needs vs what I should have for public releases. A habit I need to change, and no better way to break that habit than to have people go "your script is acting weird when I use it!" haha
1436014074
Ziechael
Forum Champion
Sheet Author
API Scripter
The all players issue is a good call actually, gives people an easy out if they don't want the script to be active on certain tokens, it was just in my test environment where i had all players on PC and NPC tokens to all multiple ways of testing various token related things as GM and player :) Will have to play around with percentages when i get chance later. Loving your work!
Certainly interesting!
1436022636
Ziechael
Forum Champion
Sheet Author
API Scripter
Okely Dokely, next request ;) The percentage works an absolute treat, i've found 33% to be effective as an indicator of poor health (in case anyone is interested). I have one more feature request if possible (i kinda feel cheeky since you have kindly written this script for free in the first place!): Would it be possible to reset the tint to null/transparent if health goes back out of the percentage config zone? Currently it will retain the last tint applied even if healed back to full health.
1436036382
DXWarlock
Sheet Author
API Scripter
Sure thing, Ill add it to the list todo. Ill have it today, or tomorrow as we are about to start our game and sometimes we lose track of time and realize its 1-2am :)
1436044548
DXWarlock
Sheet Author
API Scripter
Aura/tint turned back off if over percentage is added :)
I cant seem to get this to show. The --help command works and looks fine, but all my tokens keep showing a bar rather than an aura? I have no controller set, no linked sheets, nothing in the aura box itself... ?
1436085937

Edited 1436095157
DXWarlock
Sheet Author
API Scripter
If the mob isnt tied to a sheet as a character, it wont know its an NPC, it assumes its a regular token. Thats what Im using to figure out if its a PC, NPC, a door with HP, or a random rock/bush, and to only apply it to PC and NPC.
1436088192
Ziechael
Forum Champion
Sheet Author
API Scripter
William R. said: Aura/tint turned back off if over percentage is added :) Please forgive my ignorance but i can't see to get that to function? I'm still on v0.2 as per the OP though...
1436088305

Edited 1436088454
DXWarlock
Sheet Author
API Scripter
ah I tweaked it a bit right before I posted that was only one line changed, I need to change the version at the top..forgot to update that. (seems I tweaked it wrong, just a moment..sorry about that).
1436088607
DXWarlock
Sheet Author
API Scripter
Ok fixed. seems to work now, sorry about that Ziechael, was tweaking it mid playing a game, and forgot to change the state check, it was seeing a result and not replacing it.
1436090958
Ziechael
Forum Champion
Sheet Author
API Scripter
Certainly no need to apologise, especially to me who is simply leeching off of your hard work! I've upgraded to 0.3 now but still have persistent tinting even at higher health levels (please don't rush to address, i'm only pointing it out as a 'bug' report).
1436094840

Edited 1436097157
DXWarlock
Sheet Author
API Scripter
I found it, my mistake it should be: 'tint_color':"transparent", not 'tint_color':"", its updated :)
1436101396
Ziechael
Forum Champion
Sheet Author
API Scripter
Works like a charm... superstar!
Seconded! Everything's doing what it's supposed to for me too (with the exception of the toggle command, which I know is just a placeholder right now, but I've found that "healing" above the threshold percent works just as well in a pinch). Thanks for sharing!
1436130002
Alicia
Sheet Author
Nice script. I'm using the tint aspect versus the aura, and I'm finding when I'm using aura for a different purpose your script is turning off auras when above the appearance percentage.
1436133774
Jefe
Pro
Compendium Curator
Great script!
1436136542

Edited 1436136840
DXWarlock
Sheet Author
API Scripter
Alicia G said: Nice script. I'm using the tint aspect versus the aura, and I'm finding when I'm using aura for a different purpose your script is turning off auras when above the appearance percentage. You mean if you have it set to aura, its still resetting the tint? (and vice versa). Good point, I need to fix that, Im resetting them both as a catch all sort of reset, probably the wrong way to do it :\. Ill put in a some logic so it only resets the type you are using. I need to get around to learning github (said that a year ago, haha) so I can stop editing the post and update it there.
1436137781
Alicia
Sheet Author
William R. said: Alicia G said: Nice script. I'm using the tint aspect versus the aura, and I'm finding when I'm using aura for a different purpose your script is turning off auras when above the appearance percentage. You mean if you have it set to aura, its still resetting the tint? (and vice versa). Good point, I need to fix that, Im resetting them both as a catch all sort of reset, probably the wrong way to do it :\. Ill put in a some logic so it only resets the type you are using. I need to get around to learning github (said that a year ago, haha) so I can stop editing the post and update it there. I'm not sure about the tint if using the aura as I wasn't using it that way. I use the auras for combat/items which have a range on them so the players know what the area of effect is. For that reason I was using the tint set to go off below 50% HP. I was going to suggest using github. It's really not too complicated once you figure it out. Plus there's been instances where the code block deletes or changes code which may cause some C&P issues down the line. See the wiki page for guthub ?
1436137949

Edited 1436138102
DXWarlock
Sheet Author
API Scripter
Ive been meaning to get around to it, I got a github account, but I'm fairly certain I'm using it totally wrong,I got some evening reading to do it seems :) I do all my saving/editing on cloud9, and it has a github login, there probably is a way I could tie them out and save me 3x the work. And I updated to 0.35 it will no longer reset the tint if your using aura option, and wont reset aura if you using tint. My mistake, hopefully it didnt cause too much trouble on resetting auras for you.
1436139007
Alicia
Sheet Author
0.35 solved the issue. Apparently I won't be having a game tonight so won't be able to test out the script in a scenerio but just playing around it didn't revert the Auras. The article I linked to is if you wanted to fork the Roll20 Repositories, but I still recommend at least downloading GithHub for your OS. Then you just push any changes to Github using the application. I've never used Cloud9 so I'm not sure how it works with GitHub, which it could very well do the same thing.
that could be great
1436140082

Edited 1436140097
DXWarlock
Sheet Author
API Scripter
Thanks Alicia! between that and the cloud9 doc I found I believe I got it, updated the main post to point to the git file. Wasnt as bad as I expected.
1436178690

Edited 1436178951
DXWarlock
Sheet Author
API Scripter
v0.4 is out, switched to one command: !aura and chat buttons now toggle on and off or set values. its a bit ugly but far simpler, will work on making its pretty in next version. Also added a check to see if you have variables set now in the state, so updates should not make you reset them each time.
1436195083
Alicia
Sheet Author
Tested out the buttons and they seem to be working as they should be. Nice that don't have to reset the variables through the API now after every update. Good job
1436223654

Edited 1436225154
DXWarlock
Sheet Author
API Scripter
Thanks Alicia, if you have any issues let me know, there is bound to be some combination of tokens/aura/pc/npc I didnt think of. And updated: v 0.5: Added check so only GM's can run the !aura command. Added better looking options window when using !aura command.
1436232788
The Aaron
Pro
API Scripter
Ooooh! Nice!
1436268290

Edited 1436269793
DXWarlock
Sheet Author
API Scripter
Anyone using 0.5 move to 0.6, I had the isGM check and message before I was checking the !api command so it fussed at everyone typing they wasn't a GM. its fixed. I was mid workday doing work, learning TONS from The Aaron on advanced javascript (that I will likely forget when I need it, and ask him in 2 months how to do again), and editing the script all at the same time and didnt notice. v 0.6: Internal changes: Moved functions to AuraToolbox.(function) to exclude chances of them matching another scripts. Fixed a bad error on my part of the GM check fussing at ALL chat messages they need to be GM to use the command.
1436272148

Edited 1436277799
DXWarlock
Sheet Author
API Scripter
Ok 0.7 came out fast since I was on a roll! v 0.7: Added toggles for Names: GM can see NPC GM can see PC Player can see NPC Player can see other PC New image in topic.
1436272711
The Aaron
Pro
API Scripter
Very cool! Your interface is making mine look shabby. I'm gonna have to up my game!
1436272857

Edited 1436274566
DXWarlock
Sheet Author
API Scripter
Maybe, but yours is fancy on what it does, and actually bug free! Wish I could color the buttons, but cant seem to find a way other than the maroon color. (edit: nm just figured it out..was using the wrong 'style')
1436273232
The Aaron
Pro
API Scripter
&lt;a style="color: red; background-color: cyan; border: 2px solid white; border-radius: 1em;" href="!colored --and more"&gt;Like this?&lt;/a&gt;
1436273349
DXWarlock
Sheet Author
API Scripter
Thats it, I was trying backgroundcolor: not background-color: I blame it on being up all night :P
1436273757
The Aaron
Pro
API Scripter
Bummer! Glad you got it working... Except now my interface will look even more dated!!!
1436276077

Edited 1436277088
DXWarlock
Sheet Author
API Scripter
Probably not the right way to do it in the code but it works. v0.8 Less ugly menu
1436462727

Edited 1436462780
DXWarlock
Sheet Author
API Scripter
v0.9 Updated to better structure to help with possible conflicts with other scripts by keeping everything within its own scope. ( Thanks to TheAaron for the base template for this )