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

Setting a bar to an attribute with API bugged

1402081864
DXWarlock
Sheet Author
API Scripter
When setting a bar to an attribute, it does not update the _max correctly using say: var aSet = findObjs({_type: "attribute",name: 'Rifleammo',_characterid: who.id}); aSet = aSet[0].id; id.set("bar3_link", aSet); on a token does change the bar to the correct attribute of Rifleammo, but does not refresh whatever the max of that bar was correctly. For example say bar3 was set to Pistolammo, that was 10/10 and you use API to set it to Rifleammo, which is 40/40..bar 3 WAY overextends the bar and checking the token its 40/10 as values..picking something else, then RifleAmmo again in the dropdown corrects it.
1402085378
Lithl
Pro
Sheet Author
API Scripter
While it certainly appears to be a bug (particularly since the current value does get set automatically), you could set the bar's max value to the attribute's max value at the same time in your script. At least then your script will work as intended without waiting for a bugfix. =)
1402086708

Edited 1402086721
DXWarlock
Sheet Author
API Scripter
Ah good idea! its the simple fixes I overlook trying to make complicated ways to make it work right..lol I need to test it though. want to make sure its not part of the bug in that I'm setting the previous stats max and current to the new values (since its seems to be reading them, hope it doesn't write to them also)
1402087242

Edited 1402087264
DXWarlock
Sheet Author
API Scripter
That seems to work until its fixed. Long as I: setlink set the min and max to what the stat is already then do calculations to change the values. If I do: setlink calc new values then set min and max to that, the bar still gets wonky (not sure why..guess it needs to be set right before trying to adjust the value of it). But thanks for the simple (and now painfully obvious..lol) work around, my players wont be freaking out when they have a bar 3/4 the size of the playfeild anymore.