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 .
×

Macro troubleshooting

The following macro sometime produce an error most notably when I try to select Dext or Con first but some other times it works. I can't find what cause this or how to debug it. /roll {?{Nb|1}d100cs<5cf>96-(?{Mod|0})}<?{Stat 1 |For,?{Stat 2 |Dext,[[floor((@{For}+@{Dext})/2)]]  |Int,[[floor((@{For}+@{Int})/2)]]  |Con,[[floor((@{For}+@{Con})/2)]] |Per,[[floor((@{For}+@{Per})/2)]] |Cha,[[floor((@{For}+@{Cha})/2)]] |Luck,[[floor((@{For}+@{Luck})/2)]]         } |Dext, ?{Stat 2         |For,[[floor((@{Dext}+@{For})/2)]]         |Int,[[floor((@{Dext}+@{Int})/2)]]         |Con,[[floor((@{Dext}+@{Con})/2)]]         |Per,[[floor((@{Dext}+@{Per})/2)]]         |Cha,[[floor((@{Dext}+@{Cha})/2)]]         |Luck,[[floor((@{Dext}+@{Luck})/2)]]         } |Int,?{Stat 2         |For,[[floor((@{Int}+@{For})/2)]] |Dext,[[floor((@{Int}+@{Dext})/2)]] |Con,[[floor((@{Int}+@{Con})/2)]] |Per,[[floor((@{Int}+@{Per})/2)]] |Cha,[[floor((@{Int}+@{Cha})/2)]] |Luck,[[floor((@{Int}+@{Luck})/2)]]         } |Con, ?{Stat 2         |For,[[floor((@{Con}+@{For})/2)]] |Dext,[[floor((@{Con}+@{Dext})/2)]] |Int,[[floor((@{Con}+@{Int})/2)]] |Per,[[floor((@{Con}+@{Per})/2)]] |Cha,[[floor((@{Con}+@{Cha})/2)]] |Luck,[[floor((@{Con}+@{Luck})/2)]]         } |Per,?{Stat 2         |For,[[floor((@{Per}+@{For})/2)]] |Dext,[[floor((@{Per}+@{Dext})/2)]] |Int,[[floor((@{Per}+@{Int})/2)]] |Con,[[floor((@{Per}+@{Con})/2)]] |Cha,[[floor((@{Per}+@{Cha})/2)]] |Luck,[[floor((@{Per}+@{Luck})/2)]]         } |Cha,?{Stat 2         |For,[[floor((@{Char}+@{For})/2)]] |Dext,[[floor((@{Cha}+@{Dext})/2)]] |Int,[[floor((@{Cha}+@{Int})/2)]] |Con,[[floor((@{Cha}+@{Con})/2)]] |Per,[[floor((@{Cha}+@{Per})/2)]] |Luck,[[floor((@{Cha}+@{Luck})/2)]]         } |Luck,?{Stat 2         |For,[[floor((@{Luck}+@{For})/2)]] |Dext,[[floor((@{Luck}+@{Dext})/2)]] |Int,[[floor((@{Luck}+@{Int})/2)]] |Con,[[floor((@{Luck}+@{Con})/2)]] |Per,[[floor((@{Luck}+@{Per})/2)]] |Cha,[[floor((@{Luck}+@{Cha})/2)]]         } } Thanks for helping me.
1533436338

Edited 1533436371
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What kind of error do you get, can you post some screen caps of the thing that goes wrong. I don't see anything wrong looking at your macro, but HTML is hard to read directly :) Getting some visual representation of what's going wrong will help narrow the problem down.
I am going to go out on a limb here, and suggest that each of those sub queries you might want to change their initial "Stat" entry into "StatFor", "StatDex" etc just in case when this monsterously ugly macro parses out, the parser knows that each of those sub queries is different.
1533566338

Edited 1533566692
Scott C. said: What kind of error do you get, can you post some screen caps of the thing that goes wrong. I don't see anything wrong looking at your macro, but HTML is hard to read directly :) Getting some visual representation of what's going wrong will help narrow the problem down. The usual " There was an error with your formula. Please try again. " , I launch the macro, then select dext then, after selecting the 2nd stat, instead of rolling the dices (as it would do if I selected For for example) the error appear. One thing is for sure: nothing is wrong with the formulas inside the doublebrackets, I checked each of them individually and when I replace them by a placeholder I get the same error in the same context. Aranador said: I am going to go out on a limb here, and suggest that each of those sub queries you might want to change their initial "Stat" entry into "StatFor", "StatDex" etc just in case when this monsterously ugly macro parses out, the parser knows that each of those sub queries is different. You are telling me to change each "Stat 2" into "StatFor", "StatDex", etc right? If so then i just tried it out and sadly it does not work but thanks anyway :).
1533570683

Edited 1533570770
A couple of things I noticed from the beginning. You have an extra { at the beginning of the macro that is never closed. Secondly, you have a calculation for the critical failure, but you forgot to put it inside an inline roll. So before the two stat queries you should have /roll ?{Nb|1}d100cs<5cf>[[96-(?{Mod|0})}]] Finally, I feel like you are trying to make this macro too complicated. Do you even need a nested query? Could you not simply trust the user to not repeat the same stat for the second query? (I moved the queries into an API call so that the macro is a little cleaner to read. Any lines that start with ! are API calls and are not displayed in the Chat Window and you can reuse queries by using the same query name later on in the same macro. Nor do you need to repeat the entire query, just the name. I also added labels to the attribute calls so that you can hover to see exactly which attribute is being used in case you want to ensure that two separate attributes were used in the calculation.) !?{Nb|1} ?{Mod|0} ?{Stat 1| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] } ?{Stat 2 (Don't reuse)| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] } /r ?{Nb}d100cs<5cf>[[96-?{Mod}]]<[[floor((?{Stat 1}+?{Stat 2 (Don't reuse)})/2)]]
1533578708

Edited 1533579096
Kyle G. said: A couple of things I noticed from the beginning. You have an extra { at the beginning of the macro that is never closed. Secondly, you have a calculation for the critical failure, but you forgot to put it inside an inline roll.  The { at the begining is closed,   look: /roll {?{Nb|1}d100cs<5cf>96-(?{Mod|0})} also, there truly is no calulation for critical failure, it is always at 96. The "-(?{Mod})" is for taking into account when the GM gives arbitrary bonuses or maluses depending on context. So the start of my macro really works as intended, though I must concede it's not clear just by looking.  Kyle G. said: Finally, I feel like you are trying to make this macro too complicated. Do you even need a nested query? Could you not simply trust the user to not repeat the same stat for the second query? To be honest, I almost never trust the user and I often make things more complicated than they  needs to be. So I will probably use your solution, it looks nicer than whatever I could have come up with. Thanks by the way :) Why the original macro sometimes gives an error message and sometimes not is still a complete mystery for me so if anybody has some hindsight in that matter, I would gladly read it.
1533580954

Edited 1533581015
Elensar said: Kyle G. said: Finally, I feel like you are trying to make this macro too complicated. Do you even need a nested query? Could you not simply trust the user to not repeat the same stat for the second query? To be honest, I almost never trust the user and I often make things more complicated than they  needs to be. So I will probably use your solution, it looks nicer than whatever I could have come up with. Thanks by the way :) Well then here is the nested query version for you to use. !?{Nb|1} ?{Mod|0} ?{Stat 1| For,@{For}[For]+?{Stat 2| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] }| Dext,@{Dext}[Dext]+?{Stat 2| For,@{For}[For]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] }| Int,@{Int}[Int]+?{Stat 2| For,@{For}[For]| Dext,@{Dext}[Dext]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] }| Con,@{Con}[Con]+?{Stat 2| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Per,@{Per}[Per]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] }| Per,@{Per}[Per]+?{Stat 2| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Cha,@{Cha}[Cha]| Luck,@{Luck}[Luck] }| Cha,@{Cha}[Cha]+?{Stat 2| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Luck,@{Luck}[Luck] }| Luck,@{Luck}[Luck]+?{Stat 2| For,@{For}[For]| Dext,@{Dext}[Dext]| Int,@{Int}[Int]| Con,@{Con}[Con]| Per,@{Per}[Per]| Cha,@{Cha}[Cha] } } /r ?{Nb}d100cs<5cf>[[96-?{Mod}]]<[[floor((?{Stat 1})/2)]]
Kyle G. said Well then here is the nested query version for you to use. It works! It truly works! Thank you, this is precisely what I wanted. I am still wondering what is wrong with my version but at least I have a working macro. Thank you  again for that.