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

Order of macro commands (using !ammo)

1432230174

Edited 1432230283
I have got a problem with the following roll button macro using ammo <button type='roll' name='roll_heben' value='!ammo @{character_id} heben_frei -[[@{heben_frei}]] !ammo @{character_id} tragen_frei -[[@{tragen_frei}]] !ammo @{character_id} stemmen_frei -[[@{stemmen_frei}]] !ammo @{character_id} heben_tragen_erfolge -[[@{heben_tragen_erfolge}]] !ammo @{character_id} heben_tragen_erfolge [[[[@{str}+@{kon}]]d6sacs5cs6>5]] !ammo @{character_id} heben_frei [[@{heben}+@{heben_tragen_erfolge}*15]] !ammo @{character_id} tragen_frei [[@{tragen}+@{heben_tragen_erfolge}*10]] !ammo @{character_id} stemmen_frei [[@{stemmen}+@{heben_tragen_erfolge}*5]] /em &{template:tragkraft}{{test=Heben&Tragen}}{{heben=@{heben_frei}}}{{tragen=@{tragen_frei}}}{{stemmen=@{stemmen_frei}}}{{erfolge=@{heben_tragen_erfolge}}}'/> The time when the line of /em is executed varies and this leads to wrong results. The macro would depend on a correct order of all the commands. How could I solve this problem? Is there any way? The first 4 lines should set variables to zero. The next 4 lines would set them to their new values. heben_tragen_erfolge is the temporary variable of my roll result, such that I can reuse the roll result for the template in /em as well as for the calculation of the next 3 lines.
1432230518
The Aaron
Roll20 Production Team
API Scripter
it's not the order of results that leads to the incorrect number display. It's the Order of Operations for parsing commands. All @{} and ?{} references are resolved on the client side before sending the commands to be processed, so the API commands that are modifying them have not yet taken effect at the point their values are passed to the template. If you know the math that is going on, you could use something like {{heben=[[@{heben_frei}-1]]}} to pass the right value (assuming the !ammo is reducing by 1).
1432291009

Edited 1432292902
Damn. So if I understood that correctly it is plain impossible without another script to store the roll in a temporary variable and then reuse it in further lines of the macro because the roll will always be executed in step 6/7 way after the variables are substituted in step 3 :( Edit: Damn I hoped I could trick the system by using !cron -a 0 !ammo .... or !store !ammo !run !clearstore It does not even send the commands in the correct order, and it looks like api calls stored in !cron are not expanded either :( Hmmm.....
1432310322
The Aaron
Pro
API Scripter
It is not possible to have a Macro that stores a variable for later use. There are things that can be done to get around these problems, but they are scripting solutions. What you are describing (both the evaluation of variables after adjusting, and the calling of other scripts) is possible and exemplified in the PCPP script I wrote which both parses dice syntax on the API side, and calls another script with altered values. In that case, it takes some special work to make it happen, namely 1) passing the inline rolls and attribute references in a special syntax and 2) having a script which exposes a method to activate it.
I decided to use at the moment simply 2 buttons. One which stores the result and one which uses the stored result. It is of course more error prone and a click more but it also requires less effort.