You need to create an intermediary. The chat cannot call a function directly. You need to write a wrapper that intercepts the chat message and then - if it contains your command - IT calls your function. Here's an example of a simple chat parser that calls a function. In this case, the user would select some tokens, then type !InfoDump in the chat. (or make a macro that does the same thing) var L47FC = L47FC || {};
L47FC.DumpTokenInfo= function (token) {
log(token.get("name") + ": " + token.get("statusmarkers") + " location: " + token.get("left")/70 + ", " + token.get("top")/70 + " : " + token.get("width")/70 + ", " + token.get("height")/70);
}
on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!InfoDump") !== -1 && msg.who.indexOf("(GM)") !== -1) { log("InfoDump: " + msg); _.each(msg.selected, function(objInfo) { var obj = getObj(objInfo._type, objInfo._id); if( obj.get("_type") == "graphic" ){ if( obj.get("_subtype") == "token" ){
L47FC.DumpTokenInfo(obj); } } }); } });