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

Working on a Macro, getting error

1485401497

Edited 1485401816
Accidentally deleted my last post *facepalm* I'm working on this macro to roll for a selected token, and have it ask me what I want to roll for (to reduce the number of macros I have to have). Everything was working until I decided to add a nested roll query at the end, which would ask me for what defense I wanted to roll for. Here's the code. It's a bit messy. npc roll /w gm Rolling for @{selected|token_name}: ?{Roll for what?|Skill Level,/w gm [[3d6]] vs [[@{selected|skill level}+?{mod|0}]]|HT,/w gm [[3d6]] vs [[@{selected|ht}+?{mod|0}]]|DX,/w gm [[3d6]] vs [[@{selected|dx}+?{mod|0}]]|ST,/w gm [[3d6]] vs [[@{selected|st}+?{mod|0}]]|IQ,/w gm [[3d6]] vs [[@{selected|iq}+?{mod|0}]]|Per,/w gm [[3d6]] vs [[@{selected|per}+?{mod|0}]]|Damage,@{selected|token_name} hits for [[@{selected|bar3|max}+?{mod|0} damage!]]|Defense,?{What Defense?|Dodge,[[@{selected|dodge}+?{mod|0}]]} And if the HTML code isn't showing up above: The offending bit is highlighted
Don't replace the | or the } in @{selected|dodge}. Attributes are filled before the Roll query per the order of operation.
1485402347
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It looks like you've read the advanced roll query wiki or investigated the wiki in building this. U fortunately it looks like you've fallen into the same mistake that at least 90% of people make when they start working with nesting along with one other issue. The trap everyone makes: you've html replaced the syntax of your ability calls in the nested query. Never replace characters in an attribute/ability call.* You've currently only got a single option your defense query. While this will work, it'll bring it up as a text entry field. *I used to say this was a hard and fast rule, but have recently found a use for it when doing some complex macros utilizing API command buttons to save a selection from one roll to another while putting off prompts that may not be needed till after the button has been clicked.
1485403232

Edited 1485403337
Thanks! But I've encountered another problem. I get as far as to picking "Defense," however it doesn't ask for a modifier. Here's the code I have so far. Highlighted is what I believe to be the offending part. adding & amp; in place of & didn't help.
1485403785
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, it looks like you're missing an end curly brace. You've got a single } after the mod query which would match to the "what defense" query, but no double escaped } to end the mod query and then an unescaped } at the very end to wrap up the "roll for what" query. Double escape the bar in the mod query and add &125; immediately after the 0 in the mod query.
1485404260

Edited 1485404663
Silvyre
Forum Champion
Scott's advice is excellent, but I'm wondering if you might find a non-advanced Roll Query usable, e.g. ?{Roll for what? |    Skill Level,/w gm [[ @{selected|skill level} |    HT,/w gm [[ @{selected|ht} |    DX,/w gm [[ @{selected|dx} |    ST,/w gm [[ @{selected|st} |    IQ,/w gm [[ @{selected|iq} |    Per,/w gm [[ @{selected|per} |    Dodge,@{selected|token_name} dodges: [[ @{selected|dodge} |    Damage,@{selected|token_name} rolls damage: [[ @{selected|bar3|max}     } + ?{mod|0} ]] (vs [[3d6]]) or ?{Roll|Public, |Private,/w gm} @{selected|token_name} rolls ?{Roll for what?|    Skill Level, [[ @{selected|skill level} |    HT, HT [[ @{selected|ht} |    DX, DX [[ @{selected|dx} |    ST, ST [[ @{selected|st} |    IQ, IQ [[ @{selected|iq} |    Per, Per [[ @{selected|per} |    Dodge, Dodge [[ @{selected|dodge} |    Damage, damage: [[ @{selected|bar3|max}     } + ?{mod|0} ]] (vs [[3d6]])
1485404699

Edited 1485404754
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Always love seeing your take on a macro problem Silvyre. You've got a real knack for deconstructing them into their simplest form. Did have a question though, why the double spacing for the last two options?
1485405200

Edited 1485405256
Silvyre
Forum Champion
Scott C. said: Did have a question though, why the double spacing for the last two options? Mainly to leave space for the children of the ?{What Defense?} Roll Query, which I took out.
1485406826

Edited 1485407191
Scott C. said: Ah, it looks like you're missing an end curly brace. You've got a single } after the mod query which would match to the "what defense" query, but no double escaped } to end the mod query and then an unescaped } at the very end to wrap up the "roll for what" query. Double escape the bar in the mod query and add &125; immediately after the 0 in the mod query. Appreciate the detailed help! However, what to you mean by double escaped and unescaped? I assume double escape is when you add &amp ;, correct?
1485407216
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
yep, I don't know if it's the technically correct term, but for me unescaped is the character (e.g. } ), a single escape would be }, and then double escape would be } and so on for third and fourth ...
1485407719
The Aaron
Pro
API Scripter
Double encoded might be the proper term.   Escaping in computer science is generally a character that indicates the next is not parsed specially, for example in a quoted string where the symbol denoting the string is embedded: 'It\'s a great day'  The escaped character still appears in it's native form, it just has an indicator that it should escape regular processing.  Encoding though is representing something with something else. The same string might be encoded with a special marker that gets replaced: 'It%Q%s a great day'.  The problem character isn't present in the string now, it's encoded away. It's all semantics though. =D
1485409674

Edited 1485409751
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The great and powerful arcane Scriptomancer to the rescue with the proper terms. Thanks Aaron! Only slightly joking, can we get a special badge made for you?
1485410023
The Aaron
Pro
API Scripter
I mean, I've already got this one:&nbsp; And I can always fall back on:&nbsp; <a href="https://app.roll20.net/forum/permalink/1423307/" rel="nofollow">https://app.roll20.net/forum/permalink/1423307/</a> =D
1485410126
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
OMG, how have I not seen that before? And this will end my off-topicness to prevent someone from donning their mod hat and closing the thread :)
Here's what I did to solve this issue: just got rid of the default option altogether, and added a double escaped } to close off the "Defense" option. I don't need the default anyway! :D Thanks for the help, fellas!
1485411972
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
happy rolling