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

Help with a macro.... (Nested? I think is the term).

Hi! Hoping you can help. I currently have 6 tables, all full of random descriptive descriptions for attack outcomes these are called: Melee-Hit Melee-Miss Melee-Kill Ranged-Hit Ranged-Miss Ranged-Kill I previously had two seperate macros to run them, these were split by attack type... /desc ?{Melee: What happened?|Hit, [[1t[Melee-Hit]]]|Miss, [[1t[Melee-Miss]]]|Kill, [[1t[Melee-Kill]]]} /desc ?{Ranged: What happened?|Hit, [[1t[Ranged-Hit]]]|Miss, [[1t[Ranged-Miss]]]|Kill, [[1t[Ranged-Kill]]]} I was hoping to combine them together, simply so I had less buttons on my screen! So the plan was to produce a new macro, which had a dropdown for either 'Ranged' results or 'Melee' results... that I thought would look like this: ?{Attack Outcome?|Ranged, #Ranged-Result|Melee, #Melee-Result} However, this doesn't work. I think this is because of 'Order of Operations?' (As described  here )  My last idea was to make it a longer, messy version, where it was all put inside, inline! which looks like this: /desc ?{Attack Outcome?|Ranged,?{Ranged: What happened?|Hit, [[1t[Ranged-Hit]]]|Miss, [[1t[Ranged-Miss]]]|Kill, [[1t[Ranged-Kill]]]}|Melee,?{Ranged: What happened?|Hit, [[1t[Ranged-Hit]]]|Miss, [[1t[Ranged-Miss]]]|Kill, [[1t[Ranged-Kill]]]}} But this isn't quite right either! Can anyone provide any help? Thanks
1505654195
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi godthedj, you are attempting something called advanced roll queries. You need to replace problem characters with their html code, however, because of the order operations, do not do this for any problem character that is part of an ability or attribute call. see the wiki for more info:<a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a>
As far as my macro knowledge this isn't possible. &nbsp;The best that you could do to minimize your macros would be something along the lines of: /desc ?{Attack Outcome? | Ranged Hit, [[1t[Ranged-Hit]]] | Ranged Miss, [[1t[Ranged-Miss]]] | Ranged Kill, [[1t[Ranged-Kill]]] | Melee Hit, [[1t[Melee-Hit]]] | Melee Miss, [[1t[Melee-Miss]]] | Melee Kill, [[1t[Melee-Kill]]] }
Thanks for the replies. @Scoped. - This is exactly what I did after posting my question a few hours ago. I know it's decent fix, but doing it the other way I wanted is now almost more a matter of principal! @Scott - Well, I think I tried that. None of the code references character attibutes or abilities. I copied and pasted the whole thing into notepad and tried replacing the things like [{, and | with their html counterparts... #12dh etc, etc... - It just resulted in a messy code that didn't work at all. I don't doubt that what you're saying is correct, but I unfortunatly couldn't figure out the new code correctly....
@godthedj I completely understand. &nbsp;I hate when I can't get something to work the way I want.
1505656323
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Oh, sorry, godthedj, I misread your macro and thought you did. Your macro will work, with one small change. Global macros require a space after them in order to function, so just put a space between the macro call and the syntax of the roll query.
@scott. Sorry for the ignorance... do you mean like this... ?{Attack Outcome?|Ranged, #Ranged-Result |Melee, #Melee-Result } Literally an extra space after the #macro shown in the line above?
1505659437
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
yep, and no problem
Great. When I'm back home, I'll give it a test. Thanks!
Hey - Just to let you know that I tried that, and it still wasn't correct. - It ended up looking like this: <a href="https://s3.amazonaws.com/files.d20.io/images/39339" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/39339</a>... The first dropdown box that appears should have simply had 2 options, Ranged & Melee. - And then, once one was picked, I should get a different box, with either Hit, Miss or Kill :( The one above seems to have tried to combine a few of them all together instead. Any further guru help would be appreciated :)
1505750174
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, ok, now, we're into advanced roll query territory. Change your individual selection macros to these (note: that they will no longer work by themselves) (further note: I would highly recommend making these as character abilities as the global macros will eat the html replacements if you open and resave the macro): /desc ?{Melee: What happened? &amp;#124; Hit &amp;#44; [[1t[Melee-Hit]]] &amp;#124; Miss &amp;#44; [[1t[Melee-Miss]]] &amp;#124; Kill &amp;#44; [[1t[Melee-Kill]]] &amp;#125; /desc ?{Ranged: What happened? &amp;#124; Hit &amp;#44; [[1t[Ranged-Hit]]] &amp;#124; Miss &amp;#44; [[1t[Ranged-Miss]]] &amp;#124; Kill &amp;#44; [[1t[Ranged-Kill]]] &amp;#125; That should now work for you.
Thanks a lot. I'll give it test when I'm on my PC later. Cheers
Just a quick update to let you know that it worked perfectly! - You were also right about 'will eat the html replacements if you open and resave' . Meaning that if I do so much as OPEN the macros again to edit them, I think it will break again...! ....so I'll just avoid touching them for the time being! Thanks
1505837323
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad it's working, Happy Rolling
godthedj said: Just a quick update to let you know that it worked perfectly! - You were also right about 'will eat the html replacements if you open and resave' . Meaning that if I do so much as OPEN the macros again to edit them, I think it will break again...! ....so I'll just avoid touching them for the time being! Thanks Easiest thing to do is to keep the code in some external text editor (like Notepad++). You can then make the changes in this file and copy the code into the macro.