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

Issues with Roll template nested in query (PF2e)

December 17 (1 year ago)
Mark
Pro

Hello all. Most of my question is related to how a roll template interacts with a query.

I am trying to create a query drop down that would let you select from a list of PF2e combat maneuvers and then roll the selected item in a template so it shows up as an action in chat.

Example item: I would have many more items like this built into the query


&{template:rolls} {{charactername=@{selected|character_name}}} {{subheader=Combat Action}} {{roll01=?{Choose a combat maneuver.|

Disarm [one-action] (Athletics (+@{selected|Athletics}), **Disarm:** [one-action](https://s3.amazonaws.com/files.d20.io/images/86669372/Pcb4lIrqUua7EyhBvSJzDw/med.png) [[1d20+@{selected|Athletics}]] You try to knock something out of a creature’s grasp. Attempt an Athletics check against the target’s Reflex DC. 

**Critical Success:** You knock the item out of the target's grasp. It falls to the ground in the target's space. 

**Success:** You weaken your target's grasp on the item. Until the start of that creature's turn attempts to Disarm the target of that item gain a +2 circumstance bonus and the target takes a –2 circumstance penalty to attacks with the item or other checks requiring a firm grasp on the item. 

**Critical Failure:** You lose your balance and become flat-footed until the start of your next turn.

}}}






Current chat output




The part I'm having trouble with is I would ideally want the name of the action as a title on top and then separate boxes for what happens on a crit, success, fail, and crit fail as you do.

I have tried nesting things like {{criticalsuccess=X}} in the value of the query item but before the | and it just doesn't change anything.

I have tried using HTML entry replacement for characters like } or | and it still doesn't work.

I'd be very grateful if someone could point me to what I'm doing wrong.

December 17 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

A query is fully resolved before the roll is based to the rolltemplate. The rolltemplate won't see the query, only its result.

The part I'm having trouble with is I would ideally want the name of the action as a title on top and then separate boxes for what happens on a crit, success, fail, and crit fail as you do.

This can be done, and you'll need to construct the roll query differently. You will need to use html entities, and they can sometimes act weirdly with rolltemplates - not this is not a query issue, its specifically a "HTML entity + character sheet button rolls" issue.


I would recommend you build the macro first as a generla macro or character sheet ability, and then once it works there, converted into a character sheet baility. Don't try to do that last step first.

You currently have everything inside the roll01 key:

{{roll01=?{Choose a combat maneuver.|
Disarm [one-action] (Athletics (+@{selected|Athletics}),

You'll need to back up and start the query before the first item you want to set and ending after the last item. It seems like you were probably on the right track here:

I have tried nesting things like {{criticalsuccess=X}} in the value of the query item but before the | and it just doesn't change anything.

I have tried using HTML entry replacement for characters like } or | and it still doesn't work.

Get it working first as a macro, build the working macro and post it here, and we;ll figure out how to get it working on the character sheet.

December 18 (1 year ago)
Mark
Pro

Thank you very much for the reply GiGs!


I have created a macro for just this one item as follows



Disarm01

&{template:rolls} {{charactername=@{selected|character_name}}} {{header=Disarm}}{{subheader=Combat Action}}{{roll01=[one-action](https://s3.amazonaws.com/files.d20.io/images/86669372/Pcb4lIrqUua7EyhBvSJzDw/med.png) [[1d20+@{selected|Athletics}]] }} {{roll02=**Disarm:** You try to knock something out of a creature’s grasp. Attempt an Athletics check against the target’s Reflex DC.}}{{roll03=**Critical Success:**}}{{roll04=You knock the item out of the target's grasp. It falls to the ground in the target's space.}} {{roll05=**Success:**}}{{roll06=You weaken your target's grasp on the item. Until the start of that creature's turn attempts to Disarm the target of that item gain a +2 circumstance bonus and the target takes a –2 circumstance penalty to attacks with the item or other checks requiring a firm grasp on the item.}}{{roll07=**Critical Failure:**}}{{roll08=You lose your balance and become flat-footed until the start of your next turn.}}






Current Chat output:



Now I am trying to nest this macro inside of the query as follows


?{Choose a combat maneuver.|

Disarm [one-action] (Athletics (+@{selected|Athletics}), #Disarm01

|}


But when I do that, all that appears in chat is #Disarm01. I don't get the roll template output. How do I get it to expand the nested macro? Also will I need to create a separate macro for each individual action I want to include or is there any way to bind all of these into a single macro?

December 18 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

You'll need a lit of html substitutions in that Disarm macro.

December 18 (1 year ago)
Mark
Pro

Thanks for the quick reply:

I got as far as this

Disarm01

&{template:rolls} {{charactername=@{selected|character_name}}} {{header=Disarm}}

Which works fine, but

Disarm02

&{template:rolls} {{charactername=@{selected|character_name}}} {{header=Disarm}}

When I try and run this small piece with an HTML entity pipe,  I get "TypeError: Bt is undefined"

December 18 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

Have you html entities been converted, or is that exactly what was printed?


By the way, I don't directly help with html substitutions. It is often possible to get them to work, but it's too much hassle when better solutions exist, like chat menus.

You could create abilities in your sheet, hidden through CSS, and put them in a chat menu.

So if you persist with a macros embedded in a query, which does need html substitiutions, as opposed to chat menus, someone else will have to help you.

December 18 (1 year ago)
Mark
Pro

Understood, I do appreciate the help so far.

I am reading up on chat menus now to see if this would give me the functionality that I am looking for without being too cumbersome.

December 18 (1 year ago)
Mark
Pro

So, turns out I had been trying to make everything in general macros which was causing characters to be converted on saving. I will be working off of a macro character sheet from now on. I did get the nested query idea working but I can see what you mean about a lot of HTML substitutions. Don't regret learning more about good macro practices though. Thank you again.

December 18 (1 year ago)

Edited December 18 (1 year ago)
timmaugh
Forum Champion
API Scripter

If you don't want to both with HTML subs, you can metascript it:

!?{Choose a combat maneuver.|
Heckling,%(MuleCharacter.Heckling)|
Spaghetti Slap,%(MuleCharacter.SpaghettiSlap)|
Grumpiness,%(MuleCharacter.Grumpiness)}{&simple}

Those formations won't expand until after the query has finished, so you don't have to worry about HTML substitutions.

One downside to them not expanding before the message is handed off to the Roll20 parsers is that you can no longer rely on @{selected|attribute} constructions resolving anymore (those are resolved by Roll20, and by the time the scripts see the message, Roll20 parsing is out of the picture). Instead, you'll want to convert those to Fetch constructions to retrieve the same information: @(selected.attribute)

The final result of the original macro command you shared would look more like this, then:

!&{template:rolls} {{charactername=@(selected|character_name)}} {{header=Disarm}}{{subheader=Combat Action}}{{roll01=[one-action](https://s3.amazonaws.com/files.d20.io/images/86669372/Pcb4lIrqUua7EyhBvSJzDw/med.png) [\][\]1d20+@(selected.Athletics)\]\] }} {{roll02=**Disarm:** You try to knock something out of a creature’s grasp. Attempt an Athletics check against the target’s Reflex DC.}}{{roll03=**Critical Success:**}}{{roll04=You knock the item out of the target's grasp. It falls to the ground in the target's space.}} {{roll05=**Success:**}}{{roll06=You weaken your target's grasp on the item. Until the start of that creature's turn attempts to Disarm the target of that item gain a +2 circumstance bonus and the target takes a –2 circumstance penalty to attacks with the item or other checks requiring a firm grasp on the item.}}{{roll07=**Critical Failure:**}}{{roll08=You lose your balance and become flat-footed until the start of your next turn.}}


Of course, if you're going to go that far, you might as well have a table of those results and look up your die-roll on the chart to know what you got. Instead of presenting a bunch of text for players to have to read, digest, understand, and make a ruling on, you could just present the relevant information to the roll (e.g., if the roll is a 10, present the information for a 10; if the roll is 14, show the info for 14).

To do all of this, you'd want the MetaScriptToolbox. You'd be using SelectManager, Fetch, ZeroFrame, and Muler.

I can post an example, if you'd like.

December 18 (1 year ago)
Mark
Pro

Thanks for the reply timmaugh! That's a pretty good tip and I will absolutely be using that for constructions that are not tied to a dice roll. For your idea to fetch the dice roll, that also sounds really interesting, but I'm not such how to set the target DC before the roll goes through. Would that require the player using the macro to select a target token for the DC?

I'd be happy to get to see more examples if its no trouble for you, even if it's not perfect I would love get to see more API examples. No stress if you'd rather link me to the FAQ for MetaScriptToolbox and I can research it myself.

December 18 (1 year ago)

Edited December 18 (1 year ago)
timmaugh
Forum Champion
API Scripter

Sure...

So, now that it's a new day and I'm not half-asleep, I see something I should have changed in the original code, above... and that is that when you use a Fetch construction in a roll, you have to slow the roll down ("defer" it). This is because the order of operations will go:

Roll20 parsing (including rolls) => metascript constructions (like Fetch) => standard scripts

So when Roll20 tries to parse the roll, they'll see the Fetch construction, and it will break the parsers (syntax error). This doesn't happen with Roll20 constructions like:

@{selected|Athletics}

...because by the time the inline roll parsers look at the line, the attribute calls have been resolved out to a number.

In any case, because we'd use a Fetch construction (and we have to, because of wanting to call this from a query), we have to defer the inline roll (which is a ZeroFrame operation). That would look like this:

[\][\]1d20+@(selected|Athletics)\]\]

And since we're going to have to do that, we'll have to turn *this* command into a call to the script engine (starting with a "!")...which means that we should also include a {&simple} in *this* command, too:

!&{template:rolls} {{charactername=@(selected|character_name)}} {{header=Disarm}}{{subheader=Combat Action}}{{roll01=[one-action](https://s3.amazonaws.com/files.d20.io/images/86669372/Pcb4lIrqUua7EyhBvSJzDw/med.png[\][\]1d20+@(selected|Athletics)\]\] }} {{roll02=...}} {&simple}

Example

Perhaps a simple example would make it easier. Let's say on the character "PublicTables" I have 3 abilities: Heckline, SpaghettiSlap, and Grumpiness. They all follow this format:

!&{template:default}{{name=Heckling}}{{Standard Roll=[[1d20]]}}{{Deferred Roll=[\][\]1d20\]\]}}{{Roll Re-Use=$[[0]] + $[[1]] = [\\][\\] $[[0]] + $[[1]] \\]\\]}} {{Deferred Roll Re-Use=$[[0]] + $[[1]] + $[[2]] = [\\\][\\\]$[[0]] + $[[1]] + $[[2]] \\\]\\\]}} {&simple}

...where the only difference between them is the name portion of the template bearing the name of the ability we are running (this one is "Heckling"). Don't worry too much about what else is going on in that command line -- I'll get to that in a minute. For now, just note that you couldn't retrieve this command via normal Roll20 syntax into a query without doing HTML replacements for the various query-control characters (pipe, comma, and right-brace).

What we can do, however, is use the same query to return the Fetch construction that would (during the metascript portion of message processing) get turned into the command line that we are looking for. So, here is a command line using a Fetch construction to do just that:

!?{Which action?|
Heckling,%(PublicTables.Heckling)|
Spaghetti Slap,%(PublicTables.SpaghettiSlap)|
Grumpiness,%(PublicTables.Grumpiness)}

Something else to note is that I didn't use the pipe-character in the Fetch construction. Although you can use the pipe in Fetch constructions generally (to separate character name and ability/attribute name), you wouldn't want to do that in a query. That's why there is also a period-based Fetch syntax, which I'm using, here. (Leaving the pipe in the example query I shared in my previous post was another mistake I'll correct.)

Here is the above example run twice in succession, once picking Heckling and once picking Spaghetti Slap:


Another thing to note: the query message begins with a bang ("!"). This is because when the Fetch construction is returned from the query, I need the script engine to know it should take action on the message. Every included ability also begins with a bang and includes a {&simple}. Although I could have moved the {&simple} to the line with the initial query, and then removed the bang and the {&simple} from each individual command... and still have the query-command-line still function... that arrangement would have made it so that the individual commands could not have been run without invoking the query. That is, they would not have been able to be run individually and separate from the query -- at least they couldn't have been run in that fashion and still had any Fetch constructions (like @(selected.Athletics) ) resolve properly.

Mule Example

I can give you a proper example of looking up a value from a table (or a mule) if I understand the mechanic of how that works (I am not a Pathfinder or DnD player). I think this is where you are indicating that the success or failure level would factor in a DC level for the target?

EDIT: This requires ZeroFrame 1.1.17, which I just released after finding a bug during my testing to construct this response to you. It will be available in this week's merge, and should be installed automatically if you installed the MetaScriptToolbox from the one-click.

December 19 (1 year ago)
Mark
Pro

Thanks for the reply, timmaugh. I'm glad I could inadvertently help find a bug. I'm gonna work on practicing with the ideas you and others have given me so far and I'll check back again after the update. Thank you again for all your help and I feel some of the macro FAQs and wikis need to be updated with this information.

Edited 10:25AM (8 hours a