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

I'm having a SYNTAX error relating to referencing a macro inside of a macro.

I am having an issue with a macro I'm trying to develop, where the # when referencing a macro causes a SYNTAX error. The macro I'm using is designed to roll for a character's stats, check if that roll is within a certain range of numbers, and if it isn't, reroll all of the stats. In order to do this, I have a macro named #stat-1 which is the roll for a stat. I then want to put it through another macro to check if it is within the correct range of numbers by referencing #stat-1. However, when I try to reference the macro inside of the check, it causes a SYNTAX error. The commands I am using are these: /roll 4d6k3 [This is to roll the stat, and this is named #stat-1] ({{[[#stat-1]],0}>7}*(1-0)+0) [This is to check whether the roll is within the correct range of numbers.] What I believe the problem is after doing some testing, is when roll20 is reading code, it reads it from left to right. When the program reads the # inside of the parenthesis, it automatically flags it as a SYNTAX error without reading the macro name before doing so. If anyone knows how to fix this error, I would greatly appreciate your help! I can also provide a more in-depth explanation if need be.
1670871457
timmaugh
Roll20 Production Team
API Scripter
You're running into the order of operations . Macros are expanded before inline rolls, so the contents of your #stat-1 macro is ending up in the inline roll, and since [[/roll 4d6k3]] ...doesn't work as an inline roll, you get the syntax error. It would likely work if you reformed #stat-1 to read: [[4d6k3]] ...but that would depend on what else you have using that macro, and what you want the overall experience/flow to be.
timmaugh said: It would likely work if you reformed #stat-1 to read: [[4d6k3]] I tried this, and I'm running into a couple of issues. Changing that macro to be that and leaving the other one alone just results in the same SYNTAX error. Removing the brackets from the first macro afterward results in the formula just being input into chat, and adding /roll to the beginning results in an error. Thank you for the help, but it doesn't seem to be working. Do you have any ideas, or does anyone have a fix to this?
For the macro to expand there has to be a space after the name. So the syntax error may be coming from the inline-roll starting with a # since the macro fails to expand. Also your second macro doesn't have a /roll or square brackets to have it interpreted so if the inline-roll were to succeed only the formula would show. Try using [[4d6k3]] and [[({ {#stat-1 ,0}>7}*(1-0)+0) ]]
RainbowEncoder said: For the macro to expand there has to be a space after the name. So the syntax error may be coming from the inline-roll starting with a # since the macro fails to expand. Also your second macro doesn't have a /roll or square brackets to have it interpreted so if the inline-roll were to succeed only the formula would show. Try using [[4d6k3]] and [[({ {#stat-1 ,0}>7}*(1-0)+0) ]] This worked, thank you so much!