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

Need to call multiple API calls from a handout link

I know how to call one API call from a link in a handout. For example, `!mc moveall --target MapName Well, it seems Map Change API  does not trigger the map sound I have configured for "MapName", so it seems I'll have to take multiple steps to do it (say, using Simple Sound API). I'm hoping to not have to create a separate macro to trigger the commands. I'd rather put the multiple API calls in the link in the handout. Is there a way to do that?
1715803770

Edited 1715803813
timmaugh
Forum Champion
API Scripter
Yes, you can do this. I'm working on a way to do this even more easily, but there is a way to do this even now. First, the reason why this doesn't work (if it matters in the future) is because the Script Moderator (the sandbox) doesn't propagate events that are triggered by scripts. The only event (I think) that propagates is the chat event. This is why scripts like TokenMod and ChatSetAttr offer an "observer" registration... so when *they* make a change, they notify all of their observer functions. So if you want to write a script that would react to token changes, you would want to register to receive events from the Script Moderator (for user-generated events coming from Roll20), but you might also want to register for TokenMod events. In any caser, for your situation, you'll want to install the MetaScriptToolbox from the one-click. Then write your individual commands: !mc moveall --target MapName !splay MapNameTrack Now, the change we are going to make will be to take these 2 (or more) lines and turn them into a single command which we'll let the metascripts sort out and divide, later. That means that what we're about to do will generate a single, top-level message containing all of your command lines, then later the metascripts will turn around and issue each command in turn in its OWN message. That matters, sometimes, if there is some syntax structure that you don't want to resolve until those later messages. In practice, this is often a Roll20 construction that has to become a metascript construction, or a metascript construction that has to be "deferred" so that it isn't discovered until those downstream, dispatched messages. I don't think, looking at your command line, that you'll need that sort of alteration, but I mention it in case you want to use this trick again, later, with some command line where it WOULD matter. What you're going to do is enclose everything in ZeroFrame batching syntax .  `!{{ !mc moveall --target MapName !splay MapNameTrack }} Note that there is only ONE tick... the very first character. Individual lines no longer need it, since they will be dispatched later. We only need to make the command line for the overall, top-level message recognizable as a command line. Then, remove the line breaks. The first line break and the last line break (immediately following the double opening braces or immediately preceding the double closing braces), can simply be deleted. For the rest, you're going to replace the line breaks with this character sequence: ({&br}) Solution The final result should be something more like: `!{{ !mc moveall --target MapName ({&br}) !splay MapNameTrack }} Paste that into the URL portion of the link and it should work for you. Post back if you run into any issues.