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

Different order of operation in character sheet's ability.

Hi everyone, my name is Drako and I am passionate about Roll20 Macros. I would like to bring you a strange case: in a in-Chat-Menù macro that I was writing, I write the macro in the Chat-Box, and all was going right, then I put it in an ability of the character sheet and everything went wrong. So I looking for help in the macro section of the Roll20 Help Center and I found this: <a href="https://help.roll20.net/hc/en-us/articles/360037773133-Dice-Reference#DiceReference-MathOperatorsandFunctions" rel="nofollow">https://help.roll20.net/hc/en-us/articles/360037773133-Dice-Reference#DiceReference-MathOperatorsandFunctions</a> In this article is written that the operation that recognize the ability come before the attribute recognization. And this is correct in my case for input in Text-Chat, for API button, but not for ability comand. It's better with an example: I maked a Game (no matter if you choose a sheet or not, I have tried both cases), then I create a Character and in the Character Sheet I created an attribute called "Attribute" and two abilities called "Ability" and "Attribute_name". For the attribute I set a value, like 1, and for the ability called "Attribute_name" I set the comand "Attribute". Then in "Ability" comand I wrote the following text: @{selected|%{selected|Attribute_name}} By the order of operation it must first check the text "%{selected|Attribute_name}" and convert it in "Attribute", and after check the text "@{selected|Attribute}" and convert it in the setted value, 1. If you try to write this in the text-chat-box (by the word "selected", to work you have to select a token associated to the character sheet), all right! The value 1 appears. If you try to launch the comand in the edit section of the ability, ok... but if you try to use the ability itself, an error appears, because "No attribute was found for @{selected|%{selected}" and then "selected|Attribute". You can also write an API button, but in the nested macros there is no problems like this one: [API Button](!&amp;#13;/o &amp;#64;{selected|&amp;#37;{selected|Attribute_name}} A Button in chat appear and all went right! The value appeared is 1! I hope I have found something new and not an outdated topic, even if I tried to search the forum, without success.
This is definitely an interesting interaction but it's actually the result of the order of operations as designed (if not intended). When you put the macro text directly into chat or via an API button it goes to chat and is resolved as @{selected|%{selected|Attribute_name}} @{selected|Attribute}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Abilities expanded 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Attributes expanded But when called via an ability it goes to chat and is resolved as %{Ability}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @{selected|%{selected|Attribute_name}}&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Abilities expanded selected|%{selected|Attribute_name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Attributes expanded, error occurs selected|Attribute&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Abilities expanded again selected|Attribute&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;-- Attributes expanded again but nothing to do The same macro text would work as an attribute since once it's expanded the attribute the next thing it would do is expand abilities.
It does effectively mean that when using abilities it goes #macros then @{attributes} then %{abilities}. Similarly when using macros it effectively goes @{attributes} then %{abilities} then #macros. But the order of operations is strictly speaking accurate.
Oh... now it have sense! Thank you very much, this was very helpfull!
1655064479
Andreas J.
Forum Champion
Sheet Author
Translator
For future reference, the community wiki has a more detailed article on the Order of Operations: <a href="https://wiki.roll20.net/Order_of_Operations" rel="nofollow">https://wiki.roll20.net/Order_of_Operations</a>
Thankyou very much! For the curious ones, I resolve my problem in this way: I create an other ability. I called it "64", and in his command I wrote "@". Then I correct the ability "Ability" in this way: %{selected|64}{selected|%{selected|Attribute_name}} In this way the attribute will be recall after the expansion of the abilities and all will work fine.