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 does not return the correct result!

Here I am once again lost. I would like to present in a roll template: 1 - in the first line the name of the attribute 2 - in the second line the attribute value To do this I created a call? {Attribute | STR, DEX, CON} and would like to complete it this way: @ {selected|?{Attribute}} However, the macro does not work well, it opens the list box for the attribute but at the same time returns in chat "No attribute was found for @{selected|? {Attribute}}" After I select the attribute in the list box and confirm, the macro returns only @selected | STR in the chat and not the value of the selected attribute. Is there a way to solve?
1567781277
GiGs
Pro
Sheet Author
API Scripter
You cant put queries inside an attribute reference. Something like this  @{selected|?{Attribute}} will never work in roll20. To explain why is tricky, but it relates to the order roll20 processes macros. All attributes calls in a macro are done before all queries, so when you try the above, this part ?{Attribute} is done after  this part @{selected|<whatever>} and so that attribute call doesnt make sense to roll20. There's no way around this unfortunately. If you want to prompt for the attribute name, and the attribute value, that has to be two separate unconnected queries. The only way to achieve this, I think, is through the API.
1567781543
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Have you tried it without the spaces? ?{Attribute|STR,DEX,CON}
I do believe, that the Roll query is processed too late in the macro processing flow so that this will unfortunately not work (I believe).The only thing I can think of, is not querying for the attribute and just plainly outputting all relevant attributes in one Template, like: &{template:default}{{name=Attributes}}{{Strength=@{selected|strength_modifier}}}{{Dexterity=@{selected|dexterity_modifier}}}
Got it GiGs, thanks again for this patience exercise that has been dealing with my doubts. Keith, I tried, I only got spaces in the forum text field when I gave ctrl + ctrl + v, the macro is missing the spaces. Florian, my idea is to allow the player to select the attribute and the macro to display, in one line of the roll template the name of the attribute and in another line only the value of the attribute (because I use this field isolated in another part of the macro). This image I think helps to understand: What I would like to do is present the name of the attribute being tested and the value of the attribute, if I use a single line of the roll template I can do it, only I need to use the value of that attribute in another field later and if I repeat the query I will always have the name + value and not just value, which causes my macro not to work. The way out, which I prefer to avoid so far, is to have the player enter the attribute name manually and then, in a listbox, select the attribute value.
1567797980
GiGs
Pro
Sheet Author
API Scripter
Aaron mentioned in another thread today you can include the attribute name in single square brackets [ ] and they will be ignored by the calculation, and show up as a label. It's not exactly what you want, because both have to be on one line, and the stat will only be visible in the tool text. But, let me state this as clearly as I can - there is no way in roll20, absolutely no way at all, to do what you want without using the API. The technique Aaron mentioned would look something like this in a simple roll:  /roll 1d20+ ?{which stat?|STR,[STR]@{Strength} |CON,[CON]@{Constitution} |DEX,[DEX]@{Dexterity} } You should be able to adapt that technique to your code if you find it acceptable.