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

Can't get nested query to work.

1468653343
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
I have been staring at the same bit of code for so long, I obviously need somebody to tell me the quite obvious thing that I am overlooking.&nbsp; I have an API routine that creates some macro's for me.&nbsp; Here is some code I am having problem with.&nbsp; var brace = "&#"+"125;", bar = "&#"+"124;" this.MacroDetail( "➴Set-Targets1", "!edParse~ SetTargets : ?{How many Targets|One,this is one|Two, this is two}", true); this.MacroDetail( "➴Set-Targets3", "!edParse~ SetTargets : ?{How many Targets|One,@{target"+bar+"First Target"+bar+"token_id"+brace+"|Two, this is two}", true); Note that I specify bar and brace as I do so that the API IED does not interpret the code when it loads.&nbsp; MacroDetail just creates a macro.&nbsp; Targets1 works exactly as you would expect.&nbsp; Targets3, does not work at all, instead, when this macro is called what arrives at the API is the following. 'SetTargets : ?{How many Targets|One,target&#124;First Target&#124;token_id&#125;|Two, this is two' Notice that it is missing both @{ from after one, &nbsp; and is missing a } at the very end.&nbsp; Also notice that it does not actually process the popup asking how many targets are wanted, it just sends (most of) the text of the command it should be interpreting to the API instead of interpreting it itself. Also, (and this is something I have checked carefully), if you go look at the campaign macro's, the macro is there and looks perfect. IE: the @{ and } are there. If you copy that text to the chat window it asks for target numbers, etc.&nbsp; So what the heck am I doing wrong? I have read the macro's wiki carefully. I think I have followed all the instructions.&nbsp; I know that if I open the macro in the IED it will interpret the bar and brace, so know not to save it from there. &nbsp;I can't figure out what I am doing wrong. And finally, when I do paste the text of the saved macro into the chat windown, it behaves in the mannor described here <a href="https://app.roll20.net/forum/post/3668350/when-i-h" rel="nofollow">https://app.roll20.net/forum/post/3668350/when-i-h</a>... IE: it does not ask how many targets I want, and then ask me for that many targets, it asks me for all the targets, then asks how many I want reported. This is unacceptable and I need to get that issue solved as well. &nbsp; &nbsp; Any help would be greatly appreciated.&nbsp;
1468671785
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Chris, How are you trying to output this? are you just using sendChat('from', this)? or are you outputting an API command button? Sending rollqueries to chat directly from the API does not work (and just strips out the calls as you saw).
1468724340

Edited 1468724503
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
The routine MacroDetail above simply is supposed to create a macro. &nbsp;And as far as I can tell, the macro gets created exactly as I want it.&nbsp; If I run the macro by&nbsp;pressing the token action button,&nbsp;It is supposed to run the macro. However it does not work. Once again, if I open the macro, and manually copy everything into into the chat window, it does work somewhat better in that it asks for a target and then asks how many targets I want, and then reports exactly what I would expect from the results of the query.&nbsp; The thing that is flustering me is that it is doing different things if I run a macro than if I open a macro and paste the text of the macro into the chat window. I would expect those two things to behave exactly the same way.&nbsp; So anyway, when I press the token action button associated with this macro, that is when I get the gobbeldy-gook above.&nbsp;
1468725798
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, well, I've hit the end of my limited programming knowledge, but one thing you may not have noticed, is that this macro is always going to ask for the maximum number of targets regardless of what option you choose in the query, and will ask for them before spawning the query pop-up because attributes are resolved, then roll queries, then rolls.
1468726906
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
Yes, so if I can't get that solved I don't need to get this solved, but when I get weird stuff like this I like to figure out exactly what is biting me so I recognize it if I see it again. Still I am now activly working my way around that problem, and with luck avoiding that will avoid this problem as well.&nbsp;