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 with Passing Value between Chatsetattr to a Tokenmod Script

1607101126

Edited 1607101148
Tried to find if this was already covered in the forum without success.  Not sure how to define this but I am trying to pass a value from a Chatsetattr to a Tokenmod script. [I am writing a Lay on Hands macro (DnD 5e OGL).]  The basic pass is: !modbattr --silent --charid @{selected|character_id} --class_resource|-[[ [$Lse] ?{@{selected|character_name} has @{selected|class_resource} points available. Use?|0}]] !token-mod --ignore|selected --ids @{target|token_id} --set bar1_value|+ [$Lse] I have tried $Lse, [$Lse] and [[$Lse]] but nothing seems to work.  Any help would be appreciated.
1607101797
The Aaron
Forum Champion
API Scripter
That's a hard question to answer.  There isn't a good way of doing this with those scripts.  In fact, it would be far easier to write a one-off script that would do this in one go.  There aren't variables in Roll20 chat like that.
1607102261

Edited 1607102320
Thanks for your reply, The Aaron!  Hmmm... I was able to mimic this with a two-step for Lay on Hands on the character: !modbattr --silent --charid @{selected|character_id} --class_resource|-[[?{@{selected|character_name} has @{selected|class_resource} points available. Use?|0}]] !token-mod --set bar1_value|+[[{[[?{Points Applied?}]], [[@{selected|bar1|max} - @{selected|bar1}]]}kl1]] Converting the token mod by adding --ignore|selected @{target|token_id} to the tokenmod script works but is clunky.  How would I do this as a one-off? I've thought of adding target ids to either script but still can't see how it would work because you can't have character and target on same line using the same class_resource attribute adjustment.  Or can you?  I am not proficient enough to write API myself or I would try that.
1607102871
The Aaron
Forum Champion
API Scripter
Actually, after rereading you macro, this should work: !modbattr --silent --charid @{selected|character_id} --class_resource|-[[?{@{selected|character_name} has @{selected|class_resource} points available. Use?|0}]] !token-mod --ignore|selected --ids @{target|token_id} --set bar1_value|+[[?{@{selected|character_name} has @{selected|class_resource} points available. Use?}]] You can't pass a variable, or the result of a roll.  However, repeated Roll Queries with the same label text are all replaced with the same value, so since you're prompting, you can repeat the prompt on the TokenMod command to use the same value.
A good try - it did reduce the class_resource and kept me from having to answer the question twice but, unfortunately, failed to increase the bar1 value.  Still trying to figure out why it didn't work.
1607109300
The Aaron
Forum Champion
API Scripter
Try running it without the ! on the front of those and see what the output is?
Interesting - up until now I thought the "!" was required.  Also interesting is that it did not generate an error though it also adjusted neither the selected character's class_resource nor the target's bar1_value this time.  Hmmm...
1607113104

Edited 1607113124
The Aaron
Forum Champion
API Scripter
The ! makes it an API command.  Sorry, I should have been more explicit.  When you strip off the !, you just get chat messages which shows you what the API is going to see, so you can debug what it's going to be processing.  Can you post what the output to chart was when you stripped off the !?
Actually, there was no output except the powercard that it followed.