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

Calling a macro inside a drop-down menu

I am trying to create a token-activated macro for players to select an attack... Can anyone tell me what is wrong with my code? &{template:default} {{name=@{selected|token_name} attacks with his}}{{?{Select Attack |Shortsword, (!
#Weapon-Shortsword) |Dagger, (!
#Weapon-Dagger)}}}} Thanks in advance...
1528645772
vÍnce
Pro
Sheet Author
hmmm.  Instead of trying to roll an attack, embedded within a query and wrapped inside a roll template, how about presenting a "chat menu" of attacks? ie &{template:default} {{name=@{selected|token_name} attacks with his}}{{=[Shortsword](!
%Weapon-Shortsword) [Dagger](!
%Weapon-Dagger)}}
The usual culprit for errors with the sort of query you are doing, is the called macros need to have all the character substitutions that a query requires to function, and as such, need to be specifically written to be called, no longer able to be executed successfully outside of being called from a query.  Nor being able to be called from within a query that is within a query for that matter. Basically, queries partly parse whats inside them, and strip out certain characters.  You use code substitutions for those characters so the parsing actually puts those characters in.  Its a mess, it is difficult to explain, and it gets worse or better depending on if your macros are on a character sheet, or the global game macros. Honestly, I cant even explain the problem properly, I just know it is a problem, and avoid it all together.
1528727272

Edited 1528727328
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Try building this as a character ability instead of a collection macro (i.e. a macro written on the abilities tab of the character sheet.) You can frequently avoid dealing with substitutions there for inscrutable programming reasons. Build this on a  Macro Sheet rather than each individual character. You can then write a collections token macro usable by all players that calls the Macro Sheet ability. It's a complex workaround, but I use it in several places in my campaign. If you build the individual weapon macros as character abilities as well, the format to call them is [button_name]( ~ ability_name) , the tilde being the symbol needed to invoke the ability.
Vince said: hmmm.  Instead of trying to roll an attack, embedded within a query and wrapped inside a roll template, how about presenting a "chat menu" of attacks? ie &{template:default} {{name=@{selected|token_name} attacks with his}}{{=[Shortsword](!
%Weapon-Shortsword) [Dagger](!
%Weapon-Dagger)}} Vince...that is currently how I have it set up and it works perfectly, but I am trying to make it a drop-down menu selection...
Aranador said: The usual culprit for errors with the sort of query you are doing, is the called macros need to have all the character substitutions that a query requires to function, and as such, need to be specifically written to be called, no longer able to be executed successfully outside of being called from a query.  Nor being able to be called from within a query that is within a query for that matter. Basically, queries partly parse whats inside them, and strip out certain characters.  You use code substitutions for those characters so the parsing actually puts those characters in.  Its a mess, it is difficult to explain, and it gets worse or better depending on if your macros are on a character sheet, or the global game macros. Honestly, I cant even explain the problem properly, I just know it is a problem, and avoid it all together. Ok...thanks for that info...conclusion...I have a problem?...lol
keithcurtis said: Try building this as a character ability instead of a collection macro (i.e. a macro written on the abilities tab of the character sheet.) You can frequently avoid dealing with substitutions there for inscrutable programming reasons. Build this on a  Macro Sheet rather than each individual character. You can then write a collections token macro usable by all players that calls the Macro Sheet ability. It's a complex workaround, but I use it in several places in my campaign. If you build the individual weapon macros as character abilities as well, the format to call them is [button_name]( ~ ability_name) , the tilde being the symbol needed to invoke the ability. I have tried this as both a collections macro as well as a character ability...I keep getting the same result which is: Chapha Ootih attacks with his (! #Weapon-Shortsword) Can you please explain what you mean by "dealing with substitutions"?? I have read on the forums about macro code being substituted with html syntax...is this what you are referring to? if so, is there a write-up I can look at to understand that process? I am not clear on what you mean by building a macro sheet...I understand that you mean create a "global" character sheet for the purpose of "holding" macros usable by all the characters, but how do the tokens execute from that sheet when they are linked to their own sheets?? Please excuse my ongoing ignorance...
Yah dont worry about the ignorance - as I said, this problem is so vexing that I cant even describe the problem properly, let alone the solution. So, a query does a little bit of parsing of the information that is inside the query.  When what is inside the query is a macro, it is kind of like the parser takes the macro call, and expands it out into the full macro within the query, before the program actually executes the query.  In this process, certain characters get stripped out, because reasons.  By using character substitutions, instead of stripping out characters, this pre execution parse pass instead turns the character substitutions into the required characters, so that when the query is executed, it works. The various tricks for getting around this problem, such as having a 'macro character', or re-working the way you are approaching the problem, are all just 'out of the box' solutions, so are not immediately obvious, but they do make sense eventually. And as I said, I honestly just avoid the problem all together, by using 'chat menu' style buttons and character ability macros, so I know why you're having this problem, I just can't articulate the solution you want - because I dont really know it.
Aranador said: Yah dont worry about the ignorance - as I said, this problem is so vexing that I cant even describe the problem properly, let alone the solution. So, a query does a little bit of parsing of the information that is inside the query.  When what is inside the query is a macro, it is kind of like the parser takes the macro call, and expands it out into the full macro within the query, before the program actually executes the query.  In this process, certain characters get stripped out, because reasons.  By using character substitutions, instead of stripping out characters, this pre execution parse pass instead turns the character substitutions into the required characters, so that when the query is executed, it works. The various tricks for getting around this problem, such as having a 'macro character', or re-working the way you are approaching the problem, are all just 'out of the box' solutions, so are not immediately obvious, but they do make sense eventually. And as I said, I honestly just avoid the problem all together, by using 'chat menu' style buttons and character ability macros, so I know why you're having this problem, I just can't articulate the solution you want - because I dont really know it. Thanks for that,I really appreciate the honest answer...My current "chat menu" macros work just fine, I'm just looking for a more refined way of presenting the characters with combat options...cheers  :)