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

[PF] embedding macros into a query inside of a macro (selecting a macro from a list)

Okay so I've run into some problems trying to have a query return a specific macro to combine them. My example is having 3 macros for rolling for melee, ranged, and cmb attack chance and having a fourth macro to select a certain type of attack. my code as follows:

#AttackMelee
%{Bill|Melee-Attack-Roll}

#AttackRanged
%{Bill|Ranged-Attack-Roll}

#AttackCMB
%{Bill|CMB-Check}

#Attack
?{attack with what type?|Melee,#AttackMelee |Ranged,#AttackRanged |CMB,#AttackCMB }

I know this doesn't work for a number of reasons. Because of the way Roll20 parses the text, the text the macro represents can mess up the query and then the #Attack macro in turn. Also there is no way to make the query wait to handle the macro until after choice has been made. Does anyone know of a way to make this work without having to write the html out myself?

Note to Developers reading this:
  • You might want to introduce escape characters for symbols the next parser might use such as /} so that these characters can still be used for display purposes and the user can still specify where a macro begins and ends.
  • You might instead want to bookend macros, abilities, queries etc with nonprintable characters. One's that won't be displayed by the editor but for the parser to know what to format and what not to format without waiting until a printable character that might be needed.
  • You could also add another command character to reorder the order of operations if neccessary to call a query before a macro for example
Given how creating macros is already an advanced feature, I don't think adding one or more of these features would hinder any user, but it would make it a lot easier for those of us that know how to use them.
July 08 (9 years ago)

Edited July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Without knowing what exactly is present in the macros you're referencing in the query, I can only make some guesses, but I would guess you have ending brackets, pipes, and/or commas in your macros. You'll need to replace those with their html entities, which I'm assuming is what you meant by write the html out yourself. Unfortunately there is not another way, and doing this makes these macros only work when called from a roll query. If you don't want to html escape the problem characters there is an alternative method for making ability selection menus in the form of ability command buttons which require no special escaping in your macros and can be used to create very primitive GUIs in the chat.

EDIT: Also what sheet are you using?
my four macros are included in my original post. all they do is roll for melee, ranged and cmb attacks. My friend can make a simple html script in place of the macro to fancify it but we should just be able to call the macro itself. I tried replacing the special characters with their html equivalents but it still messes up
the sheet I am using is the character sheet for pathfinder version 0.54
July 08 (9 years ago)

Edited July 08 (9 years ago)
If you'd like some help in setting up a macro with the HTML entity replacements as outlined by Advanced Usage for Roll Queries, feel free to post the macro code of that macro. If that macro contains HTML entities, be wary that the forum will convert them. One way to avoid this is to break HTML entities with a space (e.g. & #125;).
July 08 (9 years ago)

Edited July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, that's what I thought. When you replaced the characters did you do it in the macros that you have up there or in the macros that those macros are calling?

EDIT: Also, you don't actually need those macros if you're just referencing the built in macros of the sheet. Just change your query to:
#Attack
?{attack with what type?|Melee,%{Bill|Melee-Attack-Roll} |Ranged,%{Bill|Ranged-Attack-Roll} |CMB,%{Bill|CMB-Check} }

Of course you'll still need to do all the html entity replacements in the sheet macros, but it's certainly doable. The key thing to keep in mind when doing the sheet macros though is that you not only have to do it for the macro text itself but also for any fields that are referenced in the macro (like say the description field). If you've got a comma or pipe in your description for formatting or separation of values, those have to be replaced as well.
I've already tried that and it just displays the text of the macro. I don't think I can edit the macros that are built in the sheet.
July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Can you post up what you did for html replacements for one of the sheet macros? That sounds like what has happened to me when I've missed a pipe, comma, or end bracket; or when I've accidentally replaced one of those that shouldn't have been for whatever reason.
July 08 (9 years ago)

Edited July 08 (9 years ago)
What do you mean by sheet macro? You mean what was originally

%{Bill|Melee-Attack-Roll}

? I changed it to

%{Bill& #124;Melee-Attack-Roll& #125;

When I leave the & #125; as a } it says "| undefined" and when I leave the & #124; as a | it just ignores the macro and takes the next choice in the query
July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, no, you don't want to replace anything that is in an attribute, ability or macro call (these are all resolved before the roll query and so they just become their value. You want to go into the actual character sheet. In the pathfinder sheet v 0.54, you can access the macros for pretty much anything, unless you want to edit the ability command button menus alas. For your attack macro you should find it here:

See that line that says Iterative Attacks > Options > Macro Text (down arrow) IDs >

You can edit the attack's macro there.

I also just realized that you are calling the generic melee attack button at the top. If you want to stick with that, then yeah there is no way to edit that macro.
July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
There is still a way to make a selection menu though through the magic of Ability Command Buttons
Okay... is there a way to make this work for abilities or saving throws?
July 08 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
make the ability command buttons work or the query?
a query to select which ability to check and likewise for saving throws
July 09 (9 years ago)

Edited July 09 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Well, you could make just a generic weapon and html replace that weapon's macro for use in a roll query. Otherwise, ay use the ability command buttons to make yourself a simple GUI in the chat.

EDIT: yeah the GUI is probably a better bet. I'm not sure how you'd do the saves. Plus you don't have to deal with replacing a bunch of characters with html entities.
I mean abilities as in skill checks. ie strength, dexterity etc
July 09 (9 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Well, if you're dead set on using a roll query for it, there is one way. You could recreate the macros that the sheet uses (where you can't access them directly in the sheet) in your attributes and abilities tab as custom abilities(or as global macros if you wanted) with html entities in them instead of commas, pipes, and end brackets (where appropriate). You'd then call these custom macros in your roll query. 
This seems like almost the perfect time to link this. All of the work is pretty much done if you use this macro set. It's a multi-query system where you it brings up attacks, and skills (didn't go into spells because I haven't dealt with spells before, I would recommend using the spellbook feature from the sheet if you are using one of the more recent sheet versions). If you have any questions about it, feel free to ask.