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

Trouble with drop-down query in an ability

I'm trying to make a universal token macro for my players to make saving throws. Here's what I have so far: %{selected|?{Save|Fort,fortitude|Ref,reflex|Will,will}} But when I try to use it I get this error message: TypeError: Cannot read property 'substring' of undefined Is there a fix for this, or can drop-downs not be used this way?
1552765125
GiGs
Pro
Sheet Author
API Scripter
The syntax you have isnt right. You cant have queries inside attribute names (using selected), and that % at the start doesnt work with selected. You want something more like ?{Save|Fort,@{selected|fortitude}|Ref,@{selected|reflex}|Will,@{selected|will}}
GiGs said: The syntax you have isnt right. You cant have queries inside attribute names (using selected), and that % at the start doesnt work with selected. You want something more like ?{Save|Fort,@{selected|fortitude}|Ref,@{selected|reflex}|Will,@{selected|will}} The issue with that is it only gives me the bonus to the roll, not the roll itself. Currently the macros I have look like this: ?{Save? | Fort,@{selected|whispertype} &{template:pc} {{name=^{fortitude}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|fortitude}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|fortitude_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}} | Ref,@{selected|whispertype} &{template:pc} {{name=^{reflex}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|reflex}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|reflex_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}} | Will,@{selected|whispertype} &{template:pc} {{name=^{will}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|will}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|will_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}}} I was hoping to use something like my first example with line IDs for things like skill checks and attacks, so that A) the code is condensed and easier to edit if needed; B) the ability/roll itself is always updated because it links directly to the character sheet, whereas a macro like the one above must be updated separately if any bonuses are added or removed from the roll. I don't suppose there might be a way to have queries calculated first using a script?
1552768170

Edited 1552768222
GiGs
Pro
Sheet Author
API Scripter
html entities cant be used with attribute names. What is the roll? You can do something like /roll 1d20+?{Save|Fort,@{selected|fortitude}|Ref,@{selected|reflex}|Will,@{selected|will}}
1552768214
GiGs
Pro
Sheet Author
API Scripter
as a Pro user you can pretty much do anything with a script. The trick is define what exactly you want it to do.
So right now as I have it set up, this ?{Save? | Fort,@{selected|whispertype} &{template:pc} {{name=^{fortitude}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|fortitude}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|fortitude_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}} | Ref,@{selected|whispertype} &{template:pc} {{name=^{reflex}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|reflex}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|reflex_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}} | Will,@{selected|whispertype} &{template:pc} {{name=^{will}}} {{type=save}} {{showchar=@{selected|rollshowchar}}} {{charname=@{selected|character_name}}} {{roll=[[1d20+@{selected|will}[MOD]+(@{selected|saves_condition})[CONDITION]+@{selected|rollmod_save}[QUERY]]]}} {{shownotes=@{selected|rollnotes_save}}} {{notes=@{selected|will_notes}}} {{conditionsflag=[[@{selected|saves_condition}]]}} {{conditions=@{selected|conditions_display}}}} works as intended, using the appropriate template in chat. It's set in the macro tab as a Token Action for all characters. Except, any time I want to adjust something, it reverts all the html to normal text, which messes up the drop-down function. So I have to copy/paste the html version from a document to the macro each time before editing it. If there's a way to make a script that takes this %{@{selected|character_name}|?{Save|Fort,fortitude|Ref,reflex|Will,will}} and calculates the @attribute, then the query, and applies those values to the %attribute before calculating it, it would save me a lot of time when managing all my universal macros. Similarly, it would be really useful for my players' attack Abilities. Right now, I have drop-downs for players who have multiple attacks so that all of their attacks only take up one button in their Token Actions. Since these are only applied on their character windows, I don't need to use any @{selected} any of the actions and the html doesn't get reverted after saving them, but any changes to the attack function have to be manually edited. Being able to do something like this %{<Character Name>|repeating_attacks_?{Attack|<name>,<$id>|<name>,<$id>|<name>,<$id>}_fullattack} would also save me and my players a lot of time. Do you have any suggestions on where I could look to learn how to write a script that could accomplish that?
1552771920
GiGs
Pro
Sheet Author
API Scripter
Before tackling the API script question, I see a solution to this problem:  Except, any time I want to adjust something, it reverts all the html to normal text, which messes up the drop-down function.  This is a very common issue, and its a problem that happens with macros, but not Abilities on a character sheet. There are two solutions: One, once you save a macro, never reopen it. As long as you dont open it, the html entities will be safe, and the macro will work. Second, more reliably: create a new character, called it Macros, and save their universal macros as Abilities on that character. If you share the character to ALL, players can then use that abilities on that sheet. You can call it with %{macros|attack} and it will work. And you can edit it, and the html entities will not change.
Second, more reliably: create a new character, called it Macros, and save their universal macros as Abilities on that character. If you share the character to ALL, players can then use that abilities on that sheet. You can call it with %{macros|attack} and it will work. And you can edit it, and the html entities will not change. Oh, and then I can have the macro #attack use %{macros|attack}, cool! Thank you, I never would have thought to do that :)
Also, 'selected' does seem to work for %attribute (just tested it with %{selected|initiative}), so all I really need to write a script for is adjusting the order of operations so that %attributes are calculated after queries.
1552775482
GiGs
Pro
Sheet Author
API Scripter
Do you need an actual api script, or can you now do what you need with standard macros? There's a ready-made script called Power Cards API, which is very good for doing complex rolls, but is a bit tricky to use. There's a thread where the script's maintainer helps people sort out what they need in the API forum.
I would still like to try a script that calculates queries before %attributes, for player-specific drop-downs like attacks. I'll check out Power Cards. Thanks for all the help, GiGs!