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

Branching Macros

Is it possible to make macros branch? e.g. If weapon1_melee =1 then X else Y 
No. Macros don't have any conditional 'if then' behavior. You'll need to set up multiple macros, or use the API (Pro subscriber benefit).  But if you include a more detailed explanation of what you're trying to do, it may be possible to do what you're looking for in another way, or someone else may have figured it out already.  It's helpful if you post which game system you're playing, which character sheet your game is using, and the full text of your current macros.
1618181994
vÍnce
Pro
Sheet Author
"Sort of".  If/Then type logic is not built into the default macro system.  I believe there are a few API scripts(pro perk) that can handle this to some degree. Outside of a script, you might use nested queries (warning: here be dragons...) where you have a "pre-coded" path of choices. ie Ranged or Melee if you pick ranged you have 3 options(bow, sling, dagger) if you pick Melee you have 2 choices(long sword, dagger).  Most people recommend using a series of chat menus over nested queries.
I was wondering if this might be a thing to put in the suggestion box. Weapon macros are pretty complicated in the 3.5 sheet and probably other sheets. It would be nice if it were possible to make a macro that could properly handle both melee and missile weapons. I think this would only be possible if conditional statements existed. 
1618221339
Ziechael
Forum Champion
Sheet Author
API Scripter
I won't do the whole short/medium/long answer thing from your other thread I've just replied to but in early iterations of my characters attack macros I did have branching macros using complex queries which allowed for melee v ranged options as well as ammunition selection etc etc. They were a beast to write, there are likely examples floating around the forums still, BUT once licked they weren't too hard to maintain/build on. The main issue is that everyone uses the 3.5e sheet differently (for example I put att/dam modifiers in the token bubbles for easy dynamic changes from spells, buffs, debuffs etc that only affected individual tokens rather than entire sheets... handy for those mob debuffs). I'd be happy to show a basic example at some point in the future (I'm on leave for the next couple of days and don't have any meetings in which I could dedicate some time to this instead ;) )... but for weapon selection I'd encourage you to look into chat menus, it's so much easier. However, if you are wanting to toggle between melee and ranged for a single weapon (dagger, hand axe etc) then that is absolutely doable with little effort and a single query... again, happy to show an example once I have time.
So here is my more complete thought: Macros are great at simple tasks. Macros are not great at more complex tasks. An example of a more complex task would be something like an attack in D&D 3.5. If you attempt to make a macro deal with something like an attack roll the result will be close to unmanagable at best (the user will always need to click 6 times in different windows and possibly modify numbers). IMHO the better solution would be a form-like popup that would present the most common conditions to the user so they could configure them and the option of a more ⌄ section for less freequently used conditions. The conditions in the form would persist. The idea here is that the user could configure their weapon to operate as it should without having to tinker with and customize the macro.  
1618237163
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The problem is that the macro code is more of a fancy dice roller that prints to chat and then forgets what it just did. It's not really a programming language in any meaningful sense other than a very primitive way to create one-use variables that require user interaction to create. It wouldn't be a case of "adding conditional logic", but "replacing the macro feature with something else".
1618252129

Edited 1618252417
What you might be able to do is have a form that is not a form but rather an offshoot of the character sheet with hidden portions. The character sheet itself already does this. Rather than launching the macro with the little d20 button, you open the variable sheet, set the conditions, and hit submit. The macro is run after all the variables are set in the sheet. The sheet remembers the variables because things on the character sheet are persistent. The sheet author could then make these special sheets that are only visible to the user when the macro button is clicked. This method avoids the need to have conditional branching altogether since the user is not being bombarded with requests for one-use variables.