Here ya go... it will put a red dot status marker on any tokens that are not representing a character sheet. !createattributes --?{Attribute Name|} --current --max !ca --?{Attribute Name|} --current --max --current and --max are both optional. // CREATE ATTRIBUTES ON CHARACTER SHEETS FOR SELECTED TOKENS
// BY: HoneyBadger
// VERSION: 1.0
// API COMMAND HANDLER
on("chat:message", function(msg) {
if (msg.type !== "api") return;
var command = msg.content.split(" ")[0];
var attribute = msg.content.split(" --")[1];
var current = msg.content.split(" --")[2] || "";
var max = msg.content.split(" --")[3] || "";
if (command === "!createattributes" || command === "!ca") {
if (msg.selected !== undefined) {
if (attribute === "" || attribute === undefined) {
sendChat("ERROR", "/w GM You must specify the name of the attribute you want to create.");
} else {
_.each(msg.selected, function(a) {
var token = getObj("graphic", a._id);
if (token.get("represents") != "") {
var character = getObj("character", token.get("represents"));
if (getAttrByName(character.id, attribute) === undefined) {
createObj("attribute", {
name: attribute,
current: current,
max: max,
characterid: character.id
});
} else {
sendChat("ERROR", "/w GM That attribute already exists.");
}
} else {
sendChat("ERROR", "/w GM Could not find character for tokens marked with a red dot.");
token.set("status_red", true);
}
});
}
} else {
sendChat("ERROR", "/w GM You do not have any tokens selected.");
}
}
});