Gonna use this thread to post a bunch of little snippets of code I use to make my job as DM easier. A lot of these can be replicated by other scripts, but perhaps some people intimidated by those more complex and powerful scripts will like these little snippets instead. The first one is something I wrote a long time ago to reset all the tokens on the map to full health with no status icons on the tokens. Usage: !reset-tokens This simple command can be used to quickly reset all the tokens on the map to full health and remove any status icons you have set on them, such as the red X for a dead token. Click anywhere on the map while on the Objects & Tokens layer to set your focus to the map part of the window and then hit CTRL + A to select all the tokens on that layer. Then type !reset-tokens into chat and all the tokens selected will have the status icons removed from them and their Bar1 value restored to the Bar1 max value. If you use Bar2 or Bar3 instead for hit points, change HPBar = 1 to 2 or 3 instead. // API COMMAND HANDLER
on("chat:message", function(msg) {
if (msg.type !== "api") return;
// Set tokens to full hit points and remove all status icons...
if (msg.content.split(" ")[0] === "!reset-tokens") {
var TokenID = msg.content.split(" ")[1];
var Token;
if (TokenID !== undefined) {
Token = getObj("graphic", TokenID);
if (Token !== undefined) {
Token.set("statusmarkers", "");
Token.set("bar1_value", Token.get("bar1_max"));
}
} else if (msg.selected !== undefined) {
_.each(msg.selected, function(a) {
Token = getObj("graphic", a["_id"]);
if (Token !== undefined) {
Token.set("statusmarkers", "");
Token.set("bar1_value", Token.get("bar1_max"));
}
});
} else {
log ("No tokens selected or targeted.");
}
}
});