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

Adding Macros to drop-down values

This is for a D&D 3.5 game.

I want to have one saving throw macro button for Fortitude, Reflex and Will saves.

When players click on the 'Saves' button I want them to get this drop-down list: https://screenshot.googleplex.com/9Zw5xLs6D7LiqEm (The option list at the bottom of the SS is what you see when opening the drop-down).

A player that clicks on 'Fortitude' should see: https://screenshot.googleplex.com/ALPtQW3JQNAWYDP

A player that clicks on 'Reflex' should see: https://screenshot.googleplex.com/9YGfKnX7FfTDbAM

A player that clicks on 'Will' should see:  https://screenshot.googleplex.com/wA8gBEdMK2hUebY


This is the ability I created for it:

?{Choose a Saving Throws|Fortitude, @{selected|fortitudemacro} |Reflex, @{selected|reflexmacro}|Will, @{selected|willmacro}}


I have added the 3 attributes for the character: https://screenshot.googleplex.com/BDZNaEFyr3iRLst

The values are the generated macros for each role.

fortitudemacro: &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=braces against the attack}} {{check=Fortitude check:}} {{checkroll= [[ 1d20 + [[ @{fortitude} ]] ]] }} {{notes=@{fortitudenote} }}

reflexmacro: &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=tries to dodge}} {{check=Reflex check:}} {{checkroll= [[ 1d20 + [[ @{reflex} ]] ]] }} {{notes=@{reflexnote} }}

willmacro: &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=tries to resist}} {{check=Will check:}} {{checkroll= [[ 1d20 + [[ @{will} ]] ]] }} {{notes=@{willnote} }}


This doesn't work... This is what I get when I run the macro: https://screenshot.googleplex.com/9VBzwH93adHoppv


Looking at the different parts of the Saving throw macros, I see three different parts:

subtags
check
checkroll


Since these have different values for each type of saving throws, I understand that they need to be inside the drop-down code so that the user's choice would decide the value for them.


Is what I want to do possible?


Thanks. 



October 07 (4 years ago)

None of your pictures work, as they are behind a login.

There are a ton of requests for drop down macros, and there's basically two takeaways: 

1. Nesting macros requires html substitution and can become quite complicated and not always do what you want.

2. The preferred way to approach most nested queries is to use a chat menu instead.

October 07 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

None of your screenshots work, they require a sign-in to see.

What you want to do is possible, but it's actually findishly complex to write and filled with pitfalls. The problem is when you run a macro, roll20 extracts all of the called abilities, macros, attribute values, and places them in the macro, before running it. So your macro of 

?{Choose a Saving Throws|Fortitude, @{selected|fortitudemacro} |Reflex, @{selected|reflexmacro}|Will, @{selected|willmacro}}

becomes

?{Choose a Saving Throws|Fortitude, &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=braces against the attack}} 
    {{check=Fortitude check:}} {{checkroll= [[ 1d20 + [[ @{fortitude} ]] ]] }} {{notes=@{fortitudenote} }} |
Reflex, &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=tries to dodge}} {{check=Reflex check:}} 
    {{checkroll= [[ 1d20 + [[ @{reflex} ]] ]] }} {{notes=@{reflexnote} }}|
Will, &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=tries to resist}} {{check=Will check:}} 
    {{checkroll= [[ 1d20 + [[ @{will} ]] ]] }} {{notes=@{willnote} }}}

Linebreaks and spaces added for readability.

Then all the attribute values in that are also extracted and inserted in place.

And then the macro runs. The above macro fails because it has numerous } characters, and a } character ends the query.

How to fix this is described here: https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries

In essence, you have three choices (the last being the best):

1) make a single large macro (like the above) and perform all necessary character substitutions there.

2) edit your individual macros with the necessary substitutions. That will break them for normal use - you will only be able to use them with this macro.  So you might as well do #1 above.

3) switch to using a chat menu. The code is far simpler.

With options #1 or #2, you aren't out of the woods. Because you also have a bunch of attributes like @{willnote}. If any of these contain characters that trip up a query (like a comma), the macro will still fail and you'll have to edit those attributes.. Only the chat menu avoids these problems.


For a chat menu, you can keep your original query plan and rerwite it very simply:

/w "@{selected|character_name}" &{template:default} {{name=Saving Throws}} {{[Fortitude](~selected|fortitudemacro) [Reflex](~selected|reflexmacro) [Will](~selected|willmacro)}}

This will whisper a menu of buttons in chat to the player who launched the macro, and will give them three buttons - one for each save.  That will only be seen by the player, so wont clutter up chat for everyone. When they click the relevant save, that will be seen by everyone.

I used the default template here, because I dont know the 3.5 sheet. You can change that to a 3.5 template. Give it a try.


Thank you very much for the answers. I will try the substitute and the chat option and see which one works better for me.

I have spent 3 hours trying to make it work...

Sorry about the SS, I was using a regular snipping extension but from a work computer so the login is probably a protection of some sort. Will remember to take SS from my personal computer going forward. 

October 07 (4 years ago)

Edited October 07 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

Bear in mind, the chat menu method is done already  - that one line of code I supplied is all you need.

To make the substitution work, you are going to have to carefully go through that query I posted further up, and make sure to replace onlyu the specific characters you need to - dont replace any characters in attribute calls. Most people spend hours the first time doing this fruitlessly, as its very easy to break the macro by changing characters you shouldnt.

Whereas the chat menu is easily expandable: once you start using it, you'll think of other stuff you can add to it (like stat and skill rolls), and adding each one is easy.

Thank you for the help Gigs. I have a bit of a coding background so I have some experience with escape characters. 

I was able to get it to work and it works exactly as I wanted with replacing the characters that caused the code to break.

This is the code I ended up with:

?{Choose a Saving Throws|Fortitude,&{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=braces against the attack}} 
{{check=Fortitude check:}} {{checkroll= [[ 1d20 + [[ @{fortitude} ]] ]] }} {{notes=@{fortitudenote} }} 
|Reflex, &{template:DnD35StdRoll} {{saveflag=true}}{{name=@{character_name} }} {{subtags=tries to dodge}} 
{{check=Reflex check:}} {{checkroll= [[ 1d20 + [[ @{reflex} ]] ]] }} {{notes=@{reflexnote} }}
|Will, &{template:DnD35StdRoll} {{saveflag=true}} {{name=@{character_name} }} {{subtags=tries to resist}} 
{{check=Will check:}} {{checkroll= [[ 1d20 + [[ @{will} ]] ]] }} {{notes=@{willnote} }}}

Here is how it works (hopefully the SS won't be blocked this time):

Macro button: https://prnt.sc/uv922j
Drop-down: https://prnt.sc/uv9afi

Outcome: https://prnt.sc/uv9bgf

Thanks again.



October 08 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

Nicely done!