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 .
×
Advertisement Create a free account

When Using Token_Mod is it Possible to Get a Value Stored on a Token Status Marker?

1597898639
Ajax
Pro
I was wondering if it was possible to Get a Value from a Status Marker and pass that value to another function. I can get values from the three bars on the Token but was wondering about getting another usable value (0-9) previously set on a statusmarker? Thanks for any information. -Ajax
1597912565
The Aaron
Forum Champion
API Scripter
I've got a script snippet called RealizeStatusMarkers that creates attributes for each marker. I can get that to you when I'm next at my computer. 
1597942486
Ajax
Pro
That would be fantastic, thanks.
1598024710
Ajax
Pro
bump
Here's a snippet I'm using that will decrement the number on a status marker. It removes the status marker when it hits zero.         // We now know this character had a Hexblade's Curse on someone         if(mark !== undefined){             // get the target token             var targetToken = getObj("graphic", mark.get("current"));             if(targetToken !== undefined){                 // remove the status marker on the target of the curse                 var modChar = targetToken.get(Status_HexbladesCurse);                 var modVal = parseInt(modChar);                 if(isNaN(modVal) || modVal == 0){                     // Remove the status marker                     targetToken.set(Status_HexbladesCurse, false);                 }                 else {                     // change the status marker to be one less                     modVal -= 1;                     targetToken.set(Status_HexbladesCurse, modVal.toString());                 }             } I have a constant set up at the beginning of the script of const Status_HexbladesCurse = "status_broken-skull";
1598117906
Ajax
Pro
Token_Mod will decrement the number on the status marker in one short line of text, but what I need is a way to retrieve a value stored on the status marker. Thanks for your comment.
Yep, that's in the API code snippet I posted a couple days ago:                 var modChar = targetToken.get(Status_HexbladesCurse);                 var modVal = parseInt(modChar); At that point modVal should have the number that was on the status marker. First you have to have the token object: getObj("graphic"... Then you get the token object's "status_XXX" attribute. Then just convert it to an integer.
1598375263
The Aaron
Forum Champion
API Scripter
Here's that script, sorry about the delay in getting back to you:&nbsp;&nbsp;<a href="https://app.roll20.net/forum/permalink/6614230/" rel="nofollow">https://app.roll20.net/forum/permalink/6614230/</a>
1598375383
The Aaron
Forum Champion
API Scripter
After re-reading this, I just wanted to make sure you're looking to reference attributes for a character, not looking to write Javascript code, right?
1598378666
Ajax
Pro
Yes, I know nothing about coding. Thanks.