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

A Macro, an API and a Chat Table walk into a bar

I want to do the following three things 1) Run an api that adjusts an attribute 2) Show a chat message that displays the new result 3) Run a macro that also references the affected attribute. I want it to them in the above order but I get the api result at the end, and the other 2 are reported with the pre-adjusted value. Thanks, majoza
1608263940

Edited 1608263985
The Aaron
Roll20 Production Team
API Scripter
Everything put in chat together is evaluated in the chat before being sent to the API.  If you did something like: !do-a-thing --to|some_attr !use-an-attr @{selected|some_attr} /desc I did something with @{selected|some_attr} The @{selected|some_attr} references would get evaluated first: !do-a-thing --to|some_attr !use-an-attr 23 /desc I did something with 23 Then they would be submitted.  The /desc would get processed and applied first, each of the API calls would get evaluated in turn afterward (asynchronous because it's happening on the API server a ways away).  assuming output from each, it might look like: I did something with 23 Did a thing, now have 22. Use an attr with value 23! There are two ways to deal with this: 1) pre-apply the changes in the commands: !do-a-thing --to|some_attr !use-an-attr [[@{selected|some_attr}-1]] /desc I did something with [[@{selected|some_attr}-1]] 2) use only API scripts, and only use ones that take a name of the attribute, and resolve it on the API side: !do-a-thing --to|some_attr !use-an-attr @{selected|character_id} some_attr !make-desc I did something with {selected|some_attr} That said, there might be some issues with that depending on what scripts you're using.
Thanks.  I understand better how the timing works and that will help me design better ordered macros and apis.