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

[Request] Toggle Attribute value API

So, basic request that I just cant seem to figure out, mostly because I don't know the proper call/send lines for this. I know basic(oh boy do I mean basic) Java so I know the essential idea I want, I just don't know how to do it myself and I've never seen one like it before.
All I want is to be able to toggle the value of an attribute with a single button. My party has about a half dozen toggle-stat items a piece, and having an on and off button for all of them makes their macro lists a mile long.

Here's what I'm looking for type deal.
!toggle [toggleName] [number] [attribute]
Ex. !toggle Keeyaw 7 AC (the number can be either negative or positive depending on what you want the initial effect to be)
Our fighter has a toggleable shield that he can turn on and off as a swift action. This is so he can do things like a 2-handed power attack. I was thinking of building something along the lines of

Check to see if a character has an attribute named toggleName (In this example Keeyaw)
If they do see if it's value is either true or false
If value is false, set to true and multiply number by 1.
If value if true, set to false and multiply number by -1.
Take new multiplied number and add it to the attribute. Therefore increasing or decreasing the attribute by a set amount.

Something like this is pretty simple to put together for like basic Java, but once I get into the calls and stuff for API it goes way over my head. Could someone help me out?
December 10 (10 years ago)
Gen Kitty
Forum Champion
Check https://app.roll20.net/forum/post/1257490/script-tokenmod-an-interface-to-adjusting-properties-of-a-token-from-a-macro-or-the-chat-area#post-1257490 and see if it will work for your needs. If you need it to do more, I'm sure Aaron will pounce on the request and manhandle the code into compliance. :>
December 10 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Heck yeah, I will!

POUNCE POUNCE!
December 10 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Token mod doesn't deal with attributes (yet), so it probably isn't the right one to use. I need to add that feature, as people keep asking me for it.

How soon do you need this?
It's not super important, I'm currently using Sams attribute modifier https://gist.github.com/Thequietcroc/c2fd1dcc46238... with on and off macros. But I can think of 8bazillion things my party could do in the campaign. Each with a single button using this new API.
Thank you so much for this. I'm trying to figure it all out myself, but stuff like this comes with time and patience.
December 10 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
New API == TokenMod?

Here's some I use (requires you to turn on --ids for players with: !token-mod --config players-can-ids|on ).

Apply Healing Potion:
/em applies a Potion of healing to @{target|Target|token_name}
!token-mod --set bar3_value|[[{@{target|Target|bar3}+2d4+2, @{target|Target|bar3|Max}d1}kl1]] --ids @{target|Target|token_id}

Set a status marker on a target (Rook in this case):
!token-mod --set statusmarkers|+white-tower --ids @{target|token_id}
Clear that status marker (Rook):
!token-mod --set statusmarkers|-white-tower --ids @{target|token_id}
Yah, the TokenMod.
My big issue is mostly just being able to toggle a single value to add/remove from an attribute.
Like a barbarians rage, or in this example the fighter turning on/off his shield. As it stands right now he has two macros. Keeyaw-On and Keeyaw-Off. Many other party members have tons of stuff like this, so their macro bars (both on the selected token, and ease of access bottom ones) are about half a mile long.
December 10 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Right. Can't do that with TokenMod yet. You could probably get it done with some trickery and the Ammo script, but purpose built will be the way to go. I'll see if I can't whip you something up tomorrow. Too late tonight... (silly 5e DMG keeping me up reading... =D )
Ha, awesome! Massive thanks.
And I know what you mean, I'm always looking through new 3.5e books for more information.
December 10 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
I updated TokenMod so you can do those two last examples with a single command now:
!token-mod --set statusmarkers|!white-tower --ids @{target|token_id}

I'll see about getting you an attribute toggle later today/tonight.