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 API execute a Macro?

Hello Community, I'm trying to get API script to excaute a macro when a function is called. I'm not sure how / if I can do this but this is what I'm trying to do:  on("chat:message", function(msg_orig) {     if(msg_orig.type === "api") {         var msg=_.clone(msg_orig);         msg.content = msg.content.toLowerCase();         var schedule = msg.content.split(/\s+/);         switch (schedule[0]){             // This will excaute the #WorkTime             case '!workhours':                 sendChat(msg.who, "#WorkTime");             break;         }         switch (schedule[0]){             case '!resthours':                 sendChat(msg.who, "#RestTime");             break;                      }     }    }); If anyone has any ideas, or links to the wiki i might have missed, I'd appreciate the assistance. 
Nope.
1470546180
Lithl
Pro
Sheet Author
API Scripter
But you could send the content of the macro: var macro = findObjs({ type: 'macro', name: 'example' })[0]; sendChat('System', macro.get('action')); That is, of course, assuming that the macro doesn't itself call other macros. If that's the case, you would have to parse the macro.action to find other macro calls and paste in the content of those  macros before actually calling sendChat.
1470572086
The Aaron
Pro
API Scripter
You would also need to fix up any references to @{selected} and @{target}.  Depending on what you're doing, it might be better to output a button that runs the macro instead and have the appropriate player click it.  sendChat('', '[click me](
#WorkTime)');