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

Help needed to mod a script! [chatsetattrs]

Hello! I am using the chatsetattrs script and it's working wonders but it's lacking a functionality I desperately need, and I'm not a good enough coder to sneak that particular functionality into the script, so I figured I would ask you guys to see if any of you would know of a way to do it? What I need is for the modbattr command (That mods an attribute and limits it to that attribute's max value) to use another attribute as the max instead. For instance, I have a Mana attribute and a Mana_max attribute and when I change the Mana value I don't want it to go above the Mana_max value. So, I think I've narrowed it down to rows 264-268 in the code (link to github:&nbsp; <a href="https://github.com/roll20/roll20-api-scripts/blob/master/ChatSetAttr/ChatSetAttr.js" rel="nofollow">https://github.com/roll20/roll20-api-scripts/blob/master/ChatSetAttr/ChatSetAttr.js</a> &nbsp;) if (opts.modb &amp;&amp; k === "current") {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const parsedMax =&nbsp; parseFloat(attr.get("max"));&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;moddedValue = Math.min(Math.max(moddedValue, 0), _.isNaN(parsedMax) ? Infinity : parsedMax); } newValue[k] = moddedValue; And I'm guessing what I'd need to do is get the parsedMax variable to instead use the "current" value of the Mana_max attribute I mentioned, but I'm unsure how the script could get access to that attribute? Is there a quick way to add a line of code or two to make the script find an attribute with the same name but with the _max appended and get the current value from that or would I need to send the attribute as a parameter to the function for it to see the attribute?
1584663857
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
How did you make the mana_max attribute? If it's in the html of a custom character sheet,then mana_max is the same as the max of the Mana attribute
Hmm, yeah, that seems right actually! The only problem is that the value I want as my Mana_max comes from a formula, so that input is disabled. But it doesn't seem like the script works if it compares it to a disabled input, and if I enable it, it doesn't actually calculate the formula anymore... Any idea for a workaround?
1584701880
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'll do some testing when I get home today.
Awesome, thanks!
Hey, did you have time to investigate this?