Thjazigator said: Okay so far that's what I got works fine, but I would like to add some things : Is it possible to add a target token ? Like the Macro one @{target|Name}. Using the selection maybe, first token is attacker and second is target ? Would : targetToken = getObj('graphic', msg.selected[1]._id); be correct ? This would work (assuming there are two graphics selected), but you have no way of guaranteeing which graphic is first. If you look at my snippet above, it has a variable named "args" which will contain everything from the API command message except for the command itself (it'll be an array of the message separated by spaces). This is a simple way to let you pass parameters to the API script. If I needed an API command to include something like a selected token and a target token, I would probably design the command to accept the target'd ID as a parameter. So, your macro would look something like !test @{target|token_id} , and you'd get the target token with getObjs('graphic', args[0]); . Thjazigator said: I need to capture the result of the roll, but it would be nice to have it in the chat anyway so that the player know if he succeed. How do you capture a roll AND print it in the chat ? Because I can't just use two send chat, one with the function(ops) and the other without, I would get 2 different results. That's tricky. There are a few possibilities: Unlike most events, chat:message can be triggered by API calls (specifically, sendChat). You could send the roll normally with sendChat to have it appear to the players, and then re-capture it in the API script. (You'd get msg.type === 'general' if you use just an inline roll, or msg.type === 'rollresult' if you use the /roll command.) The problem with this solution is that you need to accurately re-capture the roll and then not get into an infinite loop of sendChat. You could use the callback function in sendChat, and from within that simply post the result of the roll to the chat with a second sendChat. The problem with this solution is that it won't look particularly appealing, and it certainly won't look like a roll. You could mimic the HTML that Roll20 uses to post the roll to chat with the /direct command (which is only usable from sendChat). The problem with this solution is that it's highly complicated; you can look at HoneyBadger's power cards to see an example of this in action. There are many lines of the script devoted to replicating (and in more recent versions of the script, improving) the appearance of Roll20's inline rolls. That portion of the script also had at least three people contributing to it, including myself. Thjazigator said: How do I access the initiative turnorder with the API ? Is it stocked as an character attribute ? The turn order is stored in the campaign object as a JSON string. (JavaScript Object Notation) var turnorder = []; if (Campaign().get('turnorder') !== '') turnorder = JSON.parse(Campaign().get('turnorder')); // turnorder is an array // Each element of turnorder has the following properties: // id: the id of a graphic object, or -1 if the turnorder entry isn't associated with a graphics object // pr: the initiative value // custom: if id is -1, custom will be the name displayed in the turnorder window // ... I'm certain there's also a property for the automatic round calculation thingy, but I'm too sleepy to look it up right now // The order of items in the turnorder array is the order of items in the turnorder. // Once you're done manipulating the turnorder, you have to turn is back into JSON: Campaign().set('turnorder', JSON.stringify(turnorder)); Thjazigator said: I'm still trying to figure how to use the TableExport script from The Aaron. sendChat(msg.who,'#Table'); doesn't work, but once I get my table result, I capture it with the function(ops) and then split the string to get the +2 in tableresult|+2 ? Incidentally how do you use a rollable table in the API ? If you're trying to use #Table as a macro call, that won't work. Macros don't get parsed by the API. You could, however, look up the macro ( findObjs({ type: 'macro', name: 'Table' })[0]; for example) and use the content of the macro ( sendChat(msg.who, tableMacro.get('action')); ). Of course, if the macro contains other macro calls, you would need to recursively parse for that. To create a rollable table, use the createObj function once for the table and once for each item on the table: var theTable = createObj('rollabletable', { name: 'highlander', showplayers: true }); createObj('tableitem', { rollabletableid: theTable.id, name: 'There Can Only Be One', weight: 1 });