Here's the full script with the part needed that defines what command is... I also included the !clear command that simply removes all status icons but doesn't change any bars. I used these to reset all the tokens on a map to their fully healed, default state in my D&D campaigns. Basically, I'd just hit CTR + A and use !reset to fix them all. on("chat:message", function(msg) {
// Exit if not an api command
if (msg.type != "api") return;
// Get the API Chat Command
msg.who = msg.who.replace(" (GM)", "");
msg.content = msg.content.replace("(GM) ", "");
var command = msg.content.split(" ", 1);
// Removes all status markers from selected tokens...
// Usage: !clear
if (command == "!clear") {
_.each(msg.selected, function(obj) {
var Token = getObj("graphic", obj._id);
var DefaultIcons = "";
if (Token.get("represents") !== "") {
DefaultIcons = findObjs({_type: "attribute", name: "DefaultIcons", _characterid: Token.get("represents")})[0];
DefaultIcons = (DefaultIcons !== undefined) ? DefaultIcons.get("current") : "";
}
Token.set("statusmarkers", DefaultIcons);
});
}
// Resets selected tokens to their fully healed state...
// Usage: !reset
if (command == "!reset") {
_.each(msg.selected, function(obj) {
// Get the Token and its max bar values...
var Token = getObj("graphic", obj._id);
var Bar1Max = Token.get("bar1_max");
var Bar2Max = Token.get("bar2_max");
var Bar3Max = Token.get("bar3_max");
var DefaultIcons = "";
// If the Token represents a character, check to see if the Token
// has any default icons to set. Usage should be markername@value
// Example: grenade@2
if (Token.get("represents") !== "") {
DefaultIcons = findObjs({_type: "attribute", name: "DefaultIcons", _characterid: Token.get("represents")})[0];
DefaultIcons = (DefaultIcons !== undefined) ? DefaultIcons.get("current") : "";
}
// Reset bar values and remove all status markers except those
// marked as default icons...
if (Bar1Max !== null) Token.set("bar1_value", Bar1Max);
if (Bar2Max !== null) Token.set("bar2_value", Bar2Max);
if (Bar3Max !== null) Token.set("bar3_value", Bar3Max);
Token.set("statusmarkers", DefaultIcons);
});
}
});