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

January 26 (8 years ago)

Edited January 26 (8 years ago)
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
January 26 (8 years ago)
Don't replace the | or the } in @{selected|dodge}. Attributes are filled before the Roll query per the order of operation.
January 26 (8 years ago)
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.
  1. 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.*
  2. 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.
January 26 (8 years ago)

Edited January 26 (8 years ago)
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.
January 26 (8 years ago)
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.
January 26 (8 years ago)

Edited January 26 (8 years ago)
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]])
January 26 (8 years ago)

Edited January 26 (8 years ago)
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?
January 26 (8 years ago)

Edited January 26 (8 years ago)

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.
January 26 (8 years ago)

Edited January 26 (8 years ago)

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?
January 26 (8 years ago)
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 ...
January 26 (8 years ago)
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
January 26 (8 years ago)

Edited January 26 (8 years ago)
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?
January 26 (8 years ago)
The Aaron
Pro
API Scripter
I mean, I've already got this one: 

And I can always fall back on: https://app.roll20.net/forum/permalink/1423307/

=D
January 26 (8 years ago)
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 :)
January 26 (8 years ago)
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!
January 26 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
happy rolling