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

DXWarlock said: @ Pakki Here you go :) It wont do anything with aura 1. Only 1 Aura Custom You're amazing :3 Thanks a bunch! I'll definitely be using this! (Tested it and it works wonderfully)
Thanks for the fixes, can confirm nameplates work correctly now :)
Can you change the aura size larger tokens are getting huge auras. tried using Aura size seems not to change anything.
1489546036
DXWarlock
Sheet Author
API Scripter
Did you move the tokens to get the auras to update after changing the size? It wont dynamically update on changing in the menu, the VTT doesnt know anything has changed to trigger it.
DXWarlock said: Did you move the tokens to get the auras to update after changing the size? It wont dynamically update on changing in the menu, the VTT doesnt know anything has changed to trigger it. You could do what I did in AlterBars and my Initiative script to trigger other scripts changes, within your own script.
1489548543
DXWarlock
Sheet Author
API Scripter
How that would work for the tokens? It needs token(s) to trigger on, unless I loop through all the tokens on all the pages anytime someone uses the menu. 
DXWarlock said: How that would work for the tokens? It needs token(s) to trigger on, unless I loop through all the tokens on all the pages anytime someone uses the menu.  That you could do. Shouldn't take that long to do. Especially with the new indexing done for findObjs.
1489549724

Edited 1489549735
DXWarlock
Sheet Author
API Scripter
AH i thought it would be huge overhead, guess I can try that out. Been trying to figure out a way to do that so when people turn off auras for PC so they updated.
1489550068

Edited 1489550084
I'd test it make the changes to every token vs only the tokens on that specific page. And compare speed after that.
Thanks! Just got through my game tonight and saw you updated it! Worked like a charm. A friend was asking why I paid for pro the other day and I showed them this script. I'm pretty sure they went and signed up for pro afterwards ;-) 
Mike said: Thanks! Just got through my game tonight and saw you updated it! Worked like a charm. A friend was asking why I paid for pro the other day and I showed them this script. I'm pretty sure they went and signed up for pro afterwards ;-)  Nice. :D
1489658147

Edited 1489658273
DXWarlock
Sheet Author
API Scripter
Nice mike! Glad you like it :) But LOT better and more complex scripts than mine to buy pro for :P Side note: I managed to work out how to update all the tokens on a change in the menu. what would be a 'reasonable' execution time? Right now I'm doing it on all pages for all tokens that are viable. On my game it can find, filter, and update 204 token in around 800-900ms..that sound reasonable? Tokens Updated: 204 ms to run: 851 Or if anyone knows a faster/cleaner way to do it than this, feel free to help a brother out.         ForceUpdate = function(){             var i = 0;             var start = new Date().getTime();             var barUsed = state.HealthColors.auraBar;             var results = filterObjs(function(obj) {                  if( obj.get("type") == "graphic" &&                      obj.get("subtype") == "token" &&                      obj.get("layer") == "objects" &&                      obj.get(barUsed + "_max") !== "" &&                      obj.get(barUsed + "_value") !== "")                      return true;                     else return false;             });             _.each(results, function(obj) {                 var prev = JSON.parse(JSON.stringify(obj));                 handleToken(obj, prev);                 i++             });             var end = new Date().getTime();             GMW("Tokens Updated: " + i + "<br>ms to run: "+ (end - start))         },
1489659349

Edited 1489659522
I don't know if filterObjs shares the same speed increase that I read about with findObjs. You might be able to use those same options in findObjs instead. Either way, that's less than a second to update all those tokens... so I wouldn't mind it myself. I wouldn't be making those changes too often and most likely would be making them while testing the script. Also, what about tokens hidden on the GM Layer?
Never mind, filterObjs is four times faster for finding the tokens you want. Did a quick test and findObjs took 84ms to find all the graphics with the token subtype in the campaign while filterObjs did the same and applied the filters in 20ms.
1489660571
DXWarlock
Sheet Author
API Scripter
Same here just tested it, seems a bit faster. And that's a good point, no one will see the slight delay unless in the menu changing things, and the 1 second delay is still faster that 'wiggling' all the tokens on all the pages to get them to update.
1489660893

Edited 1489660917
DXWarlock said: Same here just tested it, seems a bit faster. And that's a good point, no one will see the slight delay unless in the menu changing things, and the 1 second delay is still faster that 'wiggling' all the tokens on all the pages to get them to update. Definitely faster than wiggling tokens indeed. Now I gotta remember what changes I made in your script before I upgrade to the newest version, lol.
1489661249
DXWarlock
Sheet Author
API Scripter
What was they? I can just add them if you want.
DXWarlock said: What was they? I can just add them if you want. I don't remember now. I may have just been working in it to figure out why AlterBar wasn't triggering HealthAura changes and such. Will just update to the latest once you post it.
1489663186

Edited 1489663344
DXWarlock
Sheet Author
API Scripter
If anyone has any unusually long process times reported when updating tokens let me know I will see if I can get it down, or add a toggle for if it should update (should be OK unless you have a HUGE amount of tokens on pages). 1.4.0 : Auto update tokens: Tokens now update on all pages when changing menu options. Menu tells you total tokens processed and time it took. Code logic changes and cleanup to follow a more logical order on PC vs NPC.
+1
1489664700

Edited 1489664771
Hah, I finally remembered/discovered what I changed... the log message in the api console. I copy TheAaron's log style for showing a script is loaded. The reason is that using the angle brackets < > causes weird color issues in the text in the console log sometimes. I'm also fairly OCD and having one log message different stuck out to me. log('-=> ' + ScriptName + ' v' + version + ' <=- [Updated: ' + Updated + ']');
1489664917
DXWarlock
Sheet Author
API Scripter
Ah was wondering what was doing that!...it was sporadic.
1489668612
The Aaron
Pro
API Scripter
DXWarlock said: Same here just tested it, seems a bit faster. And that's a good point, no one will see the slight delay unless in the menu changing things, and the 1 second delay is still faster that 'wiggling' all the tokens on all the pages to get them to update. Weird.  filterObjs() has to execute a function on each object in the entire game, whereas findObjs() SHOULD be only looking at a smaller subset of objects. based on the object you pass to it.  
1489668940
The Aaron
Pro
API Scripter
I probably would have written: _.chain(findObjs({   type: 'graphic',   subtype: 'token',   layer: 'objects' })) .filter((o)=>o.get(barUsed + "_max") !== "" && o.get(barUsed + "_value") !== "")  .each(function(obj) {   var prev = JSON.parse(JSON.stringify(obj));   handleToken(obj, prev);   i++; });
1489669017

Edited 1489669131
DXWarlock
Sheet Author
API Scripter
That's because you know how to use chain, and filter, and all that :P let me try it see how it does :) Edit: about the same as filterobj it looks like: Tokens Processed: 202 Run time in ms: 792
1489669379
The Aaron
Pro
API Scripter
Weird.  How many total objects?
1489669747
DXWarlock
Sheet Author
API Scripter
278 total, filtered down to 202, but wait just realized, that's counting in the total time it takes to update each token with HandleToken too. Comment that out its insignificant either way, 22ms vs 25ms . So 99% of the time it takes it probably my horribly inefficient HandleToken coding LOL.
1489669931
The Aaron
Pro
API Scripter
Ha!  Suppose that's possible.
1489671465

Edited 1489671481
DXWarlock
Sheet Author
API Scripter
I think it just the number of objects. Calling the time for each run of HandleToken is between 3-6 ms. Is there a way to make _.each asynchronous, instead of doing each token in order? 
1489671795
The Aaron
Pro
API Scripter
Sort of.  You could do something with _.defer(), but I don't know that it would really buy you anything unless each of those guys is waiting on some sort of I/O, which they probably aren't.  If you start getting into the case where it gets killed for heartbeats, there's some techniques we can apply.
1489713543
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
DXWarlock said: If anyone has any unusually long process times reported when updating tokens let me know I will see if I can get it down, or add a toggle for if it should update (should be OK unless you have a HUGE amount of tokens on pages). 1.4.0 : Auto update tokens: Tokens now update on all pages when changing menu options. Menu tells you total tokens processed and time it took. Code logic changes and cleanup to follow a more logical order on PC vs NPC. I use Token Sync to update across pages. Is this causing more overhead? Or is the amount of behind the scenes work trivial? Or does the task even overlap at all?
Ever since updating to V1.4 I'm getting the following message after changing any setting in !aura. The moment i go back to v1.3.3 it works fine.  "Error: No attribute or sheet field found for character_id -KOpz4LIicdmg0TDsiUl named BLOODCOLOR"
Tom said: Ever since updating to V1.4 I'm getting the following message after changing any setting in !aura. The moment i go back to v1.3.3 it works fine.  "Error: No attribute or sheet field found for character_id -KOpz4LIicdmg0TDsiUl named BLOODCOLOR" That just means the API is looking for a character sheet representing a token and using getAttrByName on it and can't find that attribute. One of your character sheets is missing the BLOODCOLOR attribute. That's all.
1489755551

Edited 1489756315
SkyCaptainXIII said: Tom said: Ever since updating to V1.4 I'm getting the following message after changing any setting in !aura. The moment i go back to v1.3.3 it works fine.  "Error: No attribute or sheet field found for character_id -KOpz4LIicdmg0TDsiUl named BLOODCOLOR" That just means the API is looking for a character sheet representing a token and using getAttrByName on it and can't find that attribute. One of your character sheets is missing the BLOODCOLOR attribute. That's all. So will I need to manually assign the BLOODCOLOR attribute to all affected sheets? Basically I have the pre-bought SKT, and I get this error on a fresh game with only this script enabled. So it would seem a bunch of the sheets aren't playing ball, but there's a lot of them! Thanks.
I think it should be creating the attribute if it doesn't exist, so that's a bug... but it's not going to affect the script since it defaults to the red blood color.
I'm getting the message below, could it be trying to add that many attributes is just crashing it? Thanks again. For reference, the error message generated was: Possible infinite loop detected, shutting down.
Not sure what's going on with that.
1489757127
DXWarlock
Sheet Author
API Scripter
Hey Tom, do you get that loop message after bringing up the menu?
I bring up the menu !aura, then try and turn it on (top option). I've reverted back to v1.3.3. I believe it was trying to change every token, which Roll20 read as 'Possible infinite loop' of adding attributes to every sheet. I'm just guessing though.
1489758147
DXWarlock
Sheet Author
API Scripter
Thats what it is I believe. Lots of tokens on pages it never saw before so its trying to update them all. comment out line 390 if(OPTION !== "MENU") Update = ForceUpdate(); to //if(OPTION !== "MENU") Update = ForceUpdate(); And see if that works.
Awesome, that fixed it! Thank you. 
1489759055
DXWarlock
Sheet Author
API Scripter
No problem at all! Guess I need to find a way to do batches of tokens at a time or stop after a certain amount and give up. It's trying to update the aura and settings on all tokens on all pages. But I suppose the Storm Kings package just has too many to try to do at once.
1489765909

Edited 1489765975
DXWarlock
Sheet Author
API Scripter
Seems checking the attributes is what takes so long. Got it down a bit, seeing if I can get it lower: Tokens Processed: 646 Run time in ms: 759 If not, maybe put in a hard limit of 500 or so tokens before it stops? Does anyone regularly use more than 500 character token on the tabletop across all pages?
1489766297
The Aaron
Pro
API Scripter
So, might be time to chat about work queues.. feel free to ping me in the usual way... =D
1489787305

Edited 1489787314
DXWarlock
Sheet Author
API Scripter
With a lot of help by The Aaron we got the time down quite a bit!  This is with about 50 unique characters pasted 20 times over various pages: Tokens Processed: 1010 Run time in ms: 242 I will get an update out today or tomorrow for this.
Where is that like button? 
Nice!!
Is it possible to go smaller then 0.01 aura? from this with a 0.01 aura to To something that size? (was dragging the token to make it that small)
1489932362
The Aaron
Pro
API Scripter
A negative radius will make the aura smaller than the token.  I don't know if you can put that in for HealthColors, but it is possible to create such from the API.
Thanks used tint. With a 90% heath. Seems to work me. Negative seems not to work.