I'm not sure I'm understanding the current command syntax that you are using. I think it is something like this: !skill:<skillname> <test/any other possible values?> I might recommend a change in syntax. Something like this: !skill <skill name> <what to do with the skill> as this breaks up the command to call the script from the command you want the script to execute, and allows you to get rid of some if statements. Also added in handling to allow users to use caps or lower case for commands And then work with it like this: on("chat:message", function(msg) {
if(msg.type === "api") {
msg.content = msg.content.toLowerCase();
var args = msg.content.split(/\s+/);
switch (args[0]){
case '!skill':
switch(args[1]){
case 'accounting':
if(args[2]==='test'){
sendChat(msg.who, "Accounting: IQ/H Defaults: IQ-6, Finance-4, Mathematics (Staitisics)-5, Merchent-5");
};
break;
case 'acrobatics':
if(args[2]==='test'){
sendChat(msg.who, "Acrobatics: DX/H Defaults: DX-6");
};
break;
case 'acting':
if(args[2]==='test'){
sendChat(msg.who, "Acting: IQ / Avarange Defaults: IQ-5, Performance-2, Public Speaking-5");
};
break;
default:
sendChat(msg.who, "Bad Skill Name");
break;
}
break;
}
}
});
Just curious, but why are you using the API for this, this seems like something that could be better handled using the standard character attributes and macros. I'm assuming that all characters will have different IQ's, Performance, Public Speaking, etc. If you want this to work for all characters, you'll need to go get that information from the character sheet anyways, and you aren't really doing anything that has to be done in the API here (unless this is just the prototype for a more complex script). EDIT 2308 CST 2016 06 16: Also, I believe the issue you were having with not getting a response was due to your placement of the ending brackets for your if's, you had essentially nested everything in to the first if. Formatting your code above so that there is a tab for each nesting looks like this: on("chat:message", function(msg) {
if(msg.type === "api" && msg.content.indexOf("!skill:accounting") !== -1) {
if(msg.content.replace("!skill:accounting", "") === "test") {
sendChat(msg.who, "Accounting: IQ/H Defaults: IQ-6, Finance-4, Mathematics (Staitisics)-5, Merchent-5");
}
if(msg.type === "api" && msg.content.indexOf("!skill:acrobatics") !== -1) {
if(msg.content.replace("!skill:accounting", "") === "test") {
sendChat(msg.who, "Acrobatics: DX/H Defaults: DX-6");
}
if(msg.type === "api" && msg.content.indexOf("!skill:acting") !== -1) {
if(msg.content.replace("!skill:acting", "") === "test") {
sendChat(msg.who, "Acting: IQ / Avarange Defaults: IQ-5, Performance-2, Public Speaking-5");
}
else {
sendChat("Bad Skill Name");
}
}
}
}
});