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 Failing; What Am I Doing Wrong?

Firstly, if I'm posting in the wrong place, feel free to move it to the correct place.  I was directed here by the Help Centre.  Anyway, my issue is pretty much what it says on the tin.  I am using a currently unsupported system (BESM 3E/4E for the curious) so I've had to craft all of the abilities and macros myself.  Since I am not in any shape or form experienced in even the most basic coding, this has involved much in the way of headaches and cursing but has mostly succeeded.   We are now in the process of moving from BESM 3E to 4E and it has a new resolution mechanic similar to D&D5E's Advantage/Disadvantage.  A basic roll is 2d6 but an minor edge enables rolling 3d6 and taking the top 2, with a major edge enabling 4d6 to be rolled.  An obstacle does the opposite.   This means that I need to incorporate this into my current macros and abilities.  I thought I'd done so, as I created this:    [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} ]] to replace the basic 2d6 So, one of the abilities looked like this: /w gm @{selected|token_name} makes an unarmed attack against @{target|token_name} /w gm [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} +@{Base-Combat} +@{ACM} +@{MelAtt-UA} +@{target|Bakemono}*@{MelAtt-Bakemono} +?{Team Metal?|0} ]] Unarmed Attack Now the above ability works. It works absolutely fine. This: [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} ]] as an ability also works fine. I have tested both of these repeatedly. Now, when I try to put either of the above into a macro, it does NOT work.  NB. With the attributes, I did remember to add 'selected' to the front of them for the macro; @{selected|Base-Combat} etc. I have several macros in my game that work perfectly fine with the standard 2d6 rolls. This: /w gm @{selected|token_name} gets [[ 2d6 +?{Which Attribute? | Body, @{selected|Body} | Mind, @{selected|Mind} | Soul, @{selected|Soul} | Body & Mind, floor((@{selected|Body}+@{selected|Mind})/2) | Body & Soul, floor((@{selected|Body}+@{selected|Soul})/2) | Mind & Soul, floor((@{selected|Mind}+@{selected|Soul})/2) | Stat Average, floor((@{selected|Body}+@{selected|Mind}+@{selected|Soul})/3)} +?{Modifier?|0} ]] on the Stat roll works fine.  If I try to replace the 2d6 part with the query above, however, it goes 'Nope!'   I hope I'm just being dense here and there's some formatting difference between macros and abilities that I'm missing or something but for the love of the Random Number Gods, can someone please help me out here? *tears hair out*
1607328896
Oosh
Sheet Author
API Scripter
Do you have an example of a macro which doesn't work? I've tried your code with the Attribute references changed, and it seems to work fine. So this works on the 5e sheet, that last macro you posted with the 2d6 replaced by the Edge Query and the Attribute names swapped. I removed the [[ outer brackets ]] from the 2d6 roll so the tooltip information is preserved: /w gm @{selected|token_name} gets [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} +?{Which Attribute? | Body, @{selected|strength_mod} | Mind, @{selected|charisma_mod} | Soul, @{selected|wisdom_mod} | Body & Mind, floor((@{selected|strength_mod}+@{selected|charisma_mod})/2) | Body & Soul, floor((@{selected|strength_mod}+@{selected|wisdom_mod})/2) | Mind & Soul, floor((@{selected|charisma_mod}+@{selected|wisdom_mod})/2) | Stat Average, floor((@{selected|strength_mod}+@{selected|charisma_mod}+@{selected|wisdom_mod})/3)} +?{Modifier?|0} ]] on the Stat roll One minor thing I'd point out - it's a good idea to put a default value into an integer Query just so someone tapping enter doesn't break the math with an empty input: ?{Edge Dice| 1 } ... you can even specify a few numbers to create a drop down so players can't enter bad things, and can also use their arrow keys to pick the number: ?{Edge Dice|1 |2 |3 |4 |5 } Without the escaped HTML it looks like this ?{Edge Dice|1|2|3|4|5}, if that makes more sense.
1607353220

Edited 1607354165
Thank you for your reply, Oosh.  The code you posted, I put back onto a character as an ability, with the attributes changed back to BESM ones and no other changes.  It worked absolutely fine.  I then put it into a macro.  It didn't work.  Specifically, it popped up a box saying 'Obstacle Dice' when I clicked to make a Standard   (not Obstacle) roll.  Going ahead and putting a 0 in the Obstacle box, makes it roll the dice but it doesn't add the Stat value.  (See screenshot below) So this:   /w gm @{selected|token_name} gets [[ 2d6 +?{Which Attribute? | Body, @{selected|Body} | Mind, @{selected|Mind} | Soul, @{selected|Soul} | Body & Mind, floor((@{selected|Body}+@{selected|Mind})/2) | Body & Soul, floor((@{selected|Body}+@{selected|Soul})/2) | Mind & Soul, floor((@{selected|Mind}+@{selected|Soul})/2) | Stat Average, floor((@{selected|Body} +@{selected|Mind} +@{selected|Soul})/3)} +?{Modifier?|0} ]] on the Stat roll works as a macro. This:   /w gm @{selected|token_name} gets [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} +?{Which Attribute? | Body, @{selected|Body} | Mind, @{selected|Mind} | Soul, @{selected|Soul} | Body & Mind, floor((@{selected|Body}+@{selected|Mind})/2) | Body & Soul, floor((@{selected|Body}+@{selected|Soul})/2) | Mind & Soul, floor((@{selected|Mind}+@{selected|Soul})/2) | Stat Average, floor((@{selected|Body} +@{selected|Mind} +@{selected|Soul})/3)} +?{Modifier?|0} ]] on the Stat roll works as an ability but does not work as a macro.   I don't have character sheets in the way that D&D 5E does because of being an unsupported system.  My character journals consist of the Bio page and the Attributes and Abilities page.   NB:  What exactly did you mean about the [[ code ]] removal?  Yes, I know I'm being dense but I've been using inline rolls for everything for so long that I don't know exactly how to safely write it without.   EDIT:  I managed to screenshot the tooltip for the failed roll:   This problem occurs when using the code in a macro.  It does not occur when using the exact same code in an ability.  
The following also works fine as an ability: /w gm @{selected|token_name} gets [[ ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2} +?{Which Attribute? | Body, @{selected|Body} | Mind, @{selected|Mind} | Soul, @{selected|Soul} | Body & Mind, floor((@{selected|Body}+@{selected|Mind})/2) | Body & Soul, floor((@{selected|Body}+@{selected|Soul})/2) | Mind & Soul, floor((@{selected|Mind}+@{selected|Soul})/2) | Stat Average, floor((@{selected|Body} +@{selected|Mind} +@{selected|Soul})/3)} +?{Which Skill? | Academic, @{selected|Skill-Academic} | Adventuring, @{selected|Skill-Adventuring} | Artistic, @{selected|Skill-Artistic} | Business, @{selected|Skill-Business} | Detective, @{selected|Skill-Detective} | Domestic, @{selected|Skill-Domestic} | Military, @{selected|Skill-Military} | Scientific, @{selected|Skill-Scientific} | Social, @{selected|Skill-Social} | Street, @{selected|Skill-Street} | Technical, @{selected|Skill-Technical} } ]] on the skill roll It fails when used as a macro.   This: /w gm @{selected|token_name} gets [[ 2d6 +?{Which Attribute? | Body, @{selected|Body} | Mind, @{selected|Mind} | Soul, @{selected|Soul} | Body & Mind, floor((@{selected|Body}+@{selected|Mind})/2) | Body & Soul, floor((@{selected|Body}+@{selected|Soul})/2) | Mind & Soul, floor((@{selected|Mind}+@{selected|Soul})/2) | Stat Average, floor((@{selected|Body} +@{selected|Mind} +@{selected|Soul})/3)} +?{Which Skill? | Academic, @{selected|Skill-Academic} | Adventuring, @{selected|Skill-Adventuring} | Artistic, @{selected|Skill-Artistic} | Business, @{selected|Skill-Business} | Detective, @{selected|Skill-Detective} | Domestic, @{selected|Skill-Domestic} | Military, @{selected|Skill-Military} | Scientific, @{selected|Skill-Scientific} | Social, @{selected|Skill-Social} | Street, @{selected|Skill-Street} | Technical, @{selected|Skill-Technical} } ]] on the skill roll works fine as an ability OR a macro.  The only change is the 2d6 being switched with the  ?{Roll Type|Standard, 2d6 | Edge, (2+?{Edge Dice&#125)d6kh2 | Obstacle, (2+?{Obstacle Dice&#125)d6kl2}
1607363179
Oosh
Sheet Author
API Scripter
Okay, I think I might see the issue. Collections macros have a problem where they lose HTML substitution (like &#125) if they're ever re-opened. I think that might be what's going wrong - the escaped right braces }} are reverting to normal text, which breaks the Query. There are a few ways to deal with it. The first (and best) is to just store all the macros on a Macro Character Sheet instead of in Collections. Ability macros don't suffer from the same problem, so they'll keep working even if you open or edit them. As long as players have access to the sheet (they only need permission, not Journal visibility... so they can't edit the sheet) they can roll from that. Or you can make them Collections macros which point to the Ability macro. If you saved the above as an Ability macro skillRoll on the sheet macros , players can access that with %{macros|skillRoll} . Or you can make a Collections macro with that reference in it, and share that with the players. This is probably the easiest option. It also makes your macros into a handy module which can be exported (as a character sheet) to other games. Alternatives are to - remove the nested Query so you don't need HTML substitution. This would probably make the roll a bit clunkier, but could be done. - store the HTML substitutions as Attributes on a character sheet, and use those in the macro. For example, store &#125 as the Attribute rBrace on the sheet html . You would then write an escaped Query like this: +?{Edge Dice@{html|rBrace} . This will stop R20 from resolving the substitutions into proper characters. It's probably more effort than the first option though.
Thank you, I'll try a couple of those options.  
I went with the references solution and looks like that's fixed.  Thank you so much!  I really appreciate your help with this.  
1607398086
Oosh
Sheet Author
API Scripter
No problem - it's a pretty annoying issue particular to Collections macros, very frustrating if you don't know about it! Be sure to post back if you have further problems, it's sure to be something someone else has had to deal with before.
I will, thank you again.