Just so that it's easily accessible, here's a skeleton script for capturing an API command: on('chat:message', function(msg) { if(msg.type != 'api') return; // we short-circuit all of the logic if the message wasn't even a !command var parts = msg.content.split(' '); // spaces are generally used to separate commands and arguments
// `parts` is an array of each "word" in the message var command = parts.shift() // removes the first element from `parts` and returns its value .substring(1) // removes the "!", which I find makes the code look cleaner -- not truly necessary .toLowerCase(); // lets the user enter !command, !COMMAND, !cOmMaNd, etc. if(command == 'burn') { // assuming "!burn" is your API command // put business logic for !burn here, such as John's post; for example: var charObj = findObjs({ type: 'character', controlledby: msg.playerid })[0]; var attribName = 'END'; var attribObj = findObjs({ type: 'attribute', characterid: charObj.id, name: attribName })[0]; if(attribObj) attribObj.set('current', attribObj.get('current') - parseInt(parts[0])); // the above code assumes each player is controlling at most one character, and // NPC characters have no controller } // you can add additional commands to the same script file by adding additional if blocks });