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

APILogic Nesting Issues

1696973251
Essen
Pro
Marketplace Creator
Hi there. When nesting IF ELSEs with APILogic. I cannot seem to get the output to be more than a single line. If I make a macro that has multiple lines, it will run fine. But calling it with IF ELSE causes issues because it's more than one line. For example. If I paste this into chat: !{& if @{character|count} = 3}Yes {&else}No {&end} {&simple} !{& if @{character|count} = 3} {&else}setattr --name character --mod --count|1 --silent {&end} both will run just fine. If I put it in a macro, it will run just fine. If I call that macro with APILogic, it throws errors. Is there some way I'm supposed to be marking off line breaks? Using <br> and \r messes things up too and it doesn't run. What am I missing? 
1697033218
timmaugh
Pro
API Scripter
Hey, Essen...  My suggestion would be to use ZeroFrame to batch up the above lines (in their macro), then use a Fetch construction to call the macro within the APILogic construction in the calling macro (which you haven't provided). The result would look something like this... Let's call the macro containing the above 2 command lines "MacroA". MacroA should be: !{{    (^) !{& if @{character|count} = 3}Yes {&else}No {&end} {^&simple}   !{& if @{character|count} = 3} {&else}setattr --name character --mod --count|1 --silent {&end} }} Then the macro that calls MacroA we'll call MacroB. I know it uses an APILogic conditional, so it would be something like: !{&if a=a}#\(MacroA){&else}Some other result{&simple}{&end} Notice that I used ZeroFrame batching deferral on the first line of the batched commands (to hide the SIMPLE tag so it didn't activate until the line was dispatched as its own outbound command), and I used a straight ZeroFrame deferral (the backslash) in the Fetch construction of MacroB to delay the retrieved macro text (multi-line) from breaking the IF conditional. In other words, things would typically resolve in the order Fetch-then-APILogic. I wanted to avoid retrieving the macro until after APILogic determined whether it needed to. That let the APILogic construction work without breaking because of the line breaks.