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

Using Drop Down Options as a vairable several times within a macro?

So I'm trying to condense a bunch of individual macros based on several variables each (Block with shield, parry with sword, parry with dagger, block a ranged attack with a shield or sword, ect) into a single macro via drop down options. I -CAN- do this easily enough as far as setting the bonus goes, got that working nice and easy. Then I wanted to get fancy because you block with a shield, you don't parry with it (Broadly speaking). I'm trying to figure out how I can have the macro automatically change "Parry" to "Block" at the end if I pick Shield as an example, without having to pick from the drop down menu a second time. I've been playing with it for a bit, but I haven't made much head way, leading to my question: Is it possible to set a drop down variable once, then reuse it in a macro several times with different results? Here's where I'm stuck: /emas @{selected|token_name} uses their ?{Weapon| Shield| Sword| Sword(Ranged)| Dagger} to ## Using the above, you just pick the variable you'll be using through the macro. This also will put the selected word in the emoted text. I've somewhat done it this way as a thought of setting the 'blank' variable for later stages, but am happy to cut that one out if I can so I can word things differently at the end of my macro. ?{Weapon| Shield, block the blow| Sword, parry the blow | Sword (Ranged), deflect the incoming shots| Dagger, parry the blow}, ## This has the same drop down variable names as above, filling in what "Weapon", however it just repeats the first one in this current format rather than grabbing the wording after the comma. rolling [[1d20+?{Weapon| Shield, @{selected|Parry}+7| Sword, @{selected|Parry}+5| Sword (Ranged), 5| Dagger, @{selected|Parry}+3} +?{Modifier|0}]]. ## This again uses the same drop down item of "Weapon" to determine what the bonus should be. Sadly, just uses the related word in the roll rather than the proper bonuses. For ease of copy / paste to futz with: /emas @{selected|token_name} uses their ?{Weapon|Shield|Sword|Sword(Ranged)|Dagger} to ?{Weapon|Shield, block the blow|Sword, parry the blow |Sword (Ranged), deflect the incoming shots|Dagger, parry the blow}, rolling [[1d20+?{Weapon|Shield, @{selected|Parry}+7|Sword, @{selected|Parry}+5|Sword (Ranged), 5|Dagger, @{selected|Parry}+3}+?{Modifier|0}]]. What this currently does simply outputs "Token name uses their Shield to Shield, rolling [[1d20+Shield]]." if I select shield as my option. What I'd -like- it to do is output "Token name uses their Shield to block the blow, rolling [[1d20+General Parry Bonus+7+Manually prompted modifier]]" Is this a case where I'd need to use the html bits (| and the like, outlined here ) to break stuff up? I've been having difficulty wrapping my head around it / finding a working example I can reverse engineer to figure it out to suit my needs. Once I have that, I should be able to toy with things enough to make things work a lot better for my NPCs and players without having 3-5 bars of token macros per token, because Rifts is insane and trying to code 'simple' macros for RAW or house rules makes my head hurt. Any help would be greatly appreciated.
1565769793
Ziechael
Forum Champion
Sheet Author
API Scripter
So you can't have the same query output different results, as you've seen, it will just take the first query result and apply that to all identical instances of that query being called. To do what you need you may have to delve into the murky waters of html replaced query nesting... I'll take a look at your example and see if I can point you in the right direction but the essence of it is this: Only use queries for the things that are different in the macro, in some cases this can be EVERYTHING bar the initial /emas etc lol Queries that resolve to numbers can be used in multiple places for different results using appropriate mathematics
1565770772

Edited 1565771020
Ziechael
Forum Champion
Sheet Author
API Scripter
Here's a first pass, untested example of how queries can be used to streamline outcomes like you describe: /emas @{selected|token_name} uses their ?{Weapon|Shield,Shield to block the blow, rolling [[ 7|Sword,Sword to parry the blow, rolling [[ 5|Sword(Ranged),Sword to deflect the incoming shots, rolling [[ 5|Dagger,Dagger to parry the blow, rolling [[ 3} + @{selected|Parry} + 1d20 + ?{Modifier|0} ]] And for readability: /emas @{selected|token_name} uses their ?{Weapon| Shield,Shield to block the blow, rolling [[ 7| Sword,Sword to parry the blow, rolling [[ 5| Sword(Ranged),Sword to deflect the incoming shots, rolling [[ 5| Dagger,Dagger to parry the blow, rolling [[ 3} + @{selected|Parry} + 1d20 + ?{Modifier|0} ]] The only html required was for the comma following the weapon block description, this could have been turned into a hyphen, colon or semicolon to remove the need for html completely ;) What I've done overall is take make the query only reflect the variation so each query result gives the weapon, it's block description and the variable part of the roll, once the query is closed the rest of the roll is added to save the need to add html to the modifier query or rekey anything that never changes. I've highlighted the query in bold for visibility. And now to the test chamber to make sure I haven't made a complete arse of myself!
1565770966
Ziechael
Forum Champion
Sheet Author
API Scripter
Phew, it works as intended ;) Rolled a 7, 2, 3 and a final 2 in testing so my digital dice curse isn't broken yet sadly... time for another sacrifice...
1565790100
GiGs
Pro
Sheet Author
API Scripter
Ziechael said: Phew, it works as intended ;) Rolled a 7, 2, 3 and a final 2 in testing so my digital dice curse isn't broken yet sadly... time for another sacrifice... Aha! I knew there was black magic involved in your mastery of html macros.
Awesome! Thank you for the help and explaining things, as well as providing the example! I can totally work with this now that I grasp exactly what it's doing and how to bend the mechanics to my will. Sadly, the Roll20 Macro system is not complex enough to let me keep my macros short like I was hoping in an effort to save database space on the roll20 side of things. The good news is you can fit a book in each one. Yes, we're talking bytes of text per macro, but that adds up over the entire user base. Curse my desire to try and be mildly efficient in my macros! For those who may find this post later and be a bit confused on how this works like I was after staring at it for a while and rereading it several times (And for my own benefit to ensure I grok it properly by retyping what was already said in my own words), here's what it's doing mechanically: The drop down menu only fills a variable once. If you want to use it to have it plug a word or number Once or Several times it'll work great, but it needs to be the same thing in each place. It can't be used the way I was hoping of having different variables as a space saving measure. The way to achieve the goal I was looking for is to effectively use the initial drop down option to fill in the entire first half of the macro after the "Emote as selected token" text, including the start of the inline dice roll "[[#". Since each macro uses the same back half of "+1d20+Other stuff]]" and ending text, you don't need to include that in the drop down option's text, but you do need the start of the [[Roll info, as the bonus is what changes each time. For example: ?{Option|One, This option gives a bonus of 1. [[1 |Two, This option gives a bonus of 2. [[2} +1d20]] This macro will give you a pop up that reads "Option:" and a drop down of "One" or "Two". Picking One will send the following to chat "This option gives a bonus of 1. [[1+1d20]]" Picking Two will send the following to chat "This option gives a bonus of 2. [[2+1d20]]" You can work on expanding complexity from there. Note: The complexity of using HTML replacements in here is only needed if you want to use a "," "|" or "}". If you can keep your grammar and sentence structure proper without them, woo! If not, use the HTML replacement text. Again, thanks a ton for the help Ziechael! Really appreciate it.
1565856409

Edited 1565856491
Ziechael
Forum Champion
Sheet Author
API Scripter
You've nailed it beautifully there... final bonus information I'll expand upon is for using queries to return a number but then use that elsewhere for different things. Example, an ability that provides +1 to attack but +3 to damage: ! ?{Is the thing on or off|Off,0|On,1} Ziechael does an attack: [[ 1d20 + <various attributes> + ?{Is the thing on or off} ]] for [[ 1d8 + (?{Is the thing on or off}*3) ]] damage. Using a simple yes/no resulting in 1 or 0 you can do an infinite number of things with a single query... depending on the math required you can change the 1 to whatever works for the calculations needed :) Final bonus knowledge dump... the first line is something I've gotten into the habit of doing in recent years. It allows me to keep my queries out of any nesting issues and I can sort them into a certain order other than the one they'd naturally come in as part of the original macro: ! ?{Option A|No,0|Yes,2} ?{Option B|Banana|Sausage|Fish} ?{Option C|1-handed,1d6|2-handed,1d8} Ziechael does an attack with his ?{Option B}: [[1d20 + <various attributes> + ?{Option A}]] for [[?{Option C} + (?{Option A}+1)]] damage! The advantage of the above, beyond query sorting, is that if you were putting the attack etc as part of a nested query your only html replacement would be to turn  ?{Option A}  into  ?{Option A}  rather than having to do the full thing:  ?{Option A | No , 0 | Yes , 2 }
1565906235

Edited 1565906386
I've never seen the ! prefix before. Is that somewhere on the wiki and I've just missed it? That is a really cool tidbit of knowledge from a readability stand point in macros and one I -KNOW- I'm going to abuse the ever living heck out of. Just to once more ensure I understand the context of the prefix: The ! prefix will send no data to the chat log, however when used within the confines of a macro, it will set a variable that can be pulled later on in the macro if you use it with variables such as the drop down or direct text input fields. The use of this would be to make your macro (as shown in the second line of your examples easier to read as to what field goes where, where as my initial example has a huge blob of text smack in the middle of the action, resulting in difficulty in readability. Plus, doing it this way, you can totally skip the need to use html replacements in your actual macro text! That's the biggest bonus, without a doubt. Secondary note: You can use this in straight up text as well. Holding Shift + Enter in chat enters a line break to break in chat, letting you do multiple lines of text at once. I otherwise also really like the multiplicative option you've shown with setting values as 0 for if stuff is on or off. That wasn't something I'd taken into consideration before, and will be -really- useful considering how crazy various bonuses can get in various calculations. Not gonna do a 'my translation' break down on that bit because your macro is straight forward for ways to make that work. Once more, thank you for taking your time to help explain this. Hugely appreciated!
1565908599
Ziechael
Forum Champion
Sheet Author
API Scripter
The ! prefix basically tells the chat that 'this line is an API command... do not print to chat' but since it is highly unlikely that any API you have installed will be looking for a row of queries it just allows you to do some sorting. If nesting you'll still need to html replace the final } in the query recalls but you don't have to worry about the | and , part of it at least. Ultimately though it sounds like you've got a solid grasp of the concepts despite my often convoluted way of explaining things lol... now go forth and create macros worthy of the Gods themselves! (For context my training came from running a 4 year 3.5e DnD game... they don't get more complex than high level players for that system lol)