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

Macro variables

1449159521

Edited 1449159578
Sorry if this question was asked before but how can I store variables for the duration of a macro ? I would like to do something like this : var myToken = @{target|token_id} And be able to reuse myToken in my macro. I know I can create a macro #Get-Token-ID  but if my macro is multiline, I have to make a target for every command. Any thoughts ? PS : English is not my native language. Sorry for bad grammar/conjugation.
1449161386
The Aaron
Roll20 Production Team
API Scripter
For a multi line macro, the @{target|&lt;name&gt;|&lt;attribute&gt;} will be the same for the same value of &lt;name&gt;: /em attacks @{target|foe|name} Attacking @{target|foe|bar1} AC Target has @{target|foe|bar3} HP This will prompt for a target named foe one time and will access the various properties of that same target for name, bar1 and bar3. See:&nbsp; <a href="https://wiki.roll20.net/Macros#Advanced_Usag" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usag</a> In the case of multiple API scripts, you can pass the same token id to them in a similar fashion: !do-something-to @{target|foe|token_id} !do-another-thing-to @{target|foe|token_id} This will prompt once for a target named foe and pass the same token_id to the two different script commands.
Exactly what I need ! Thanks ! (this sould be added to the wiki)
1449171621
The Aaron
Roll20 Production Team
API Scripter
Good Point! &nbsp;I'm surprised it wasn't there already but I have added it to the Advanced Usage Section. &nbsp;Thanks for the suggestion!
Two, related things, I have also notice : 1) Query are proceed before all commands 2) The "same token name trick" also work for number query, like this /roll 2d20 +&nbsp;?{Modifier|0} /em strike ennemy with ?{Modifier|0} bonus damage!
1449181063
The Aaron
Roll20 Production Team
API Scripter
Correct on both counts. &nbsp; You can review the Order of Operations for the order things are processed: &nbsp; <a href="https://wiki.roll20.net/Dice_Reference#Order_of_Op" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Order_of_Op</a>... You can see more info about the Roll Queries (and it actually notes that the same name will result in the same value) here: <a href="https://wiki.roll20.net/Dice_Reference#Roll_Querie" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Roll_Querie</a>...