Ah! Well THAT I can help with. =D You could try starting here: <a href="https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern" rel="nofollow">https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern</a> <a href="https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1</a> <a href="https://app.roll20.net/forum/post/6237754/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6237754/slug%7D</a> And chances are, there are other posts to cover any other problems you run into. To answer the "how can I call it from a macro" question more directly, a macro (or ability, or the chat area) would most easily activate an API script by using an API Command. An API Command is any message where the first character of the message is a ! such as: !do-my-thing with my args The API is Event Driven, which means that all scripts are only ever executed once, when the API Sandbox starts up (when someone joins the game and it's not running, or when you save a script and it restarts). Their responsibility during that execution is to register functions which will respond to various events. In the case of an API command, the event you are interested in is chat:message. A simple chat:message event handler might look like this: on('chat:message',(msg) => {
if( 'api' === msg.type && /^!do-my-thing\b/i.test(msg.content)){
sendChat('demo script', 'You ran <code>!do-my-thing</code>!');
}
}); (Note: this is using Javascript ES6+ syntax, so don't worry if you know javascript and this looks like gibberish. Just read the links above and you'll feel loads better!) There are events for most of what the humans do, so you can react to them. After setting up your chat:message event handler, you'd just have the Macro call it and Bob's yer uncle. Post back with whatever questions you have. =D Also, we have a (mostly up-to-date) wiki: <a href="https://wiki.roll20.net/API:Introduction" rel="nofollow">https://wiki.roll20.net/API:Introduction</a>