
I am trying to write a simple api to roll a d20 and add a called attribute. !SC Dex would roll a d20 and add the value from the 'Dex' attribute. No errors... but no response to commands either. What have I done wrong? // :S
on("chat:message", function (msg) {
if (msg.type == "api" && msg.content.indexOf("!SC ") === 0)
{
var statType = msg.content.split(" ");
var selected = msg.selected;
_.each(selected, function(obj)
{
var tok = getObj("graphic", obj._id);
var chara = tok.get("represents");
var stat = findObjs(({ _type: "attribute", name: statType, _characterid: chara },{caseInsensitive: true})[0]);
if (typeof stat == 'undefined')
{
sendChat(msg.chara,"/w gm I did it wrong");
}else{
sendChat(msg.chara,"I rolled a [[1d20" + stat + "]] for the check!");
}
}
)}
});