Allows Status Marking via macros. This can be combined with other macros/scripts easily. Simply add the command to another line of your macro and it should be processed. v1.0 Initial v1.1 Added !setaura command. Can now set aura of selected/targeted tokens To access this scripts functions one can simply do one of the following. Declare the variable. var MarkStatus = MarkStatus || {} or var ApiCommands = ApiCommands ||{} Call the functions: MarkStatus.addStatusMarkers(token,statusmarkers) or ApiCommands["!addstatus"](token,statusmarkers) MarkStatus.remStatusMarkers (token,statusmarkers) or ApiCommands["!remstatus"](token,statusmarkers) MarkStatus.toggleStatusMarkers (token,statusmarkers) or ApiCommands["!togstatus"](token,statusmarkers) MarkStatus.clearStatusMarkers (token,statusmarkers) or ApiCommands["!clrstatus"](token) Commands: !addstatus <token_id> <status_marker> Adds a the given status markers to the specified tokens. The <token_id> can be a list of id's separated by comma. The <status_marker> can be a list of status markers separated by comma. // Add the green, blue, and purple marker to the selected token. !addstatus @{selected|token_id} green,blue,purple // adds a angel-outfit,green,archery-target markers to two tokens using the target function (you select the tokens after the macro runs) !addstatus @{target|t1|token_id},@{target|t2|token_id} angel-outfit,green,archery-target !remstatus <token_id> <status_marker> // Remove the specified markers from the selected tokens !remstatus @{selected|token_id} green,blue,purple !togstatus <token_id> <status_marker> // Toggle the specific markers for the target tokens !togstatus @{selected|token_id} green,blue,purple !clrstatus <token_id> // Clear all markers from the specified tokens !clrstatus @{selected|token_id} !setaura <token_id> <aura1|aura2> <radius> <color> <isSquare(true|false)> // Set aura1 radius to 10 and color to red and make it square !setaura @{selected|token_id} aura1 10 red true // Set aura2 radius to 17, color to #55FF55 and make is circle !setaura @{selected|token_id} aura2 10 #55ff55 false // turn off aura2; this can be done two ways, set the radius value to off or the color to transparent !setaura @{selected|token_id} aura2 off #55ff55 false OR !setaura @{selected|token_id} aura2 10 transparent false Aura Predefined colors: red, blue, green, yellow, purple, white, black, transparent You can set your own predefined colors by adding them to AuraColors variable at the top of the macro. var AuraColors = { ... } Example Macros Marking Macros - Each person chooses a status marker that he'll use when he marks a target. Fighter: all-for-one Warlord: trophy Paladin: angel-outfit Fighter Macro - This will add his mark and removes everyone elses !addstatus @{target|token_id} all-for-one !remstatus @{target|token_id} trophy,angel-outfit Warlord Macro - This will add his mark and removes everyone elses !addstatus @{target|token_id} trophy !remstatus @{target|token_id} all-for-one,angel-outfit Paladin Macro - This will add his mark and removes everyone elses !addstatus @{target|token_id} angel-outfit !remstatus @{target|token_id} all-for-one,trophy Note about script: This script may look unusual. I use a custom message processor that processes all incoming messages (api or chat). However, I wanted the option to allow the script to be standalone (no dependencies). As such it is important to ensure the following line is not changed to allow the on chat:message callback to be registered. var UsingCmdMsgProcessor = false; Script: // VARIABLE & FUNCTION DECLARATIONS -- DO NOT ALTER!!
var ApiCommands = ApiCommands || {};
var Scripts = Scripts || {};
/* Status Markers in the order of the GUI
"red", "blue", "green", "brown", "purple", "pink", "yellow", "dead",
"skull", "sleepy", "half-heart", "half-haze", "interdiction", "snail", "lightning-helix", "spanner",
"chained-heart", "chemical-bolt", "death-zone", "drink-me", "edge-crack", "ninja-mask", "stopwatch", "fishing-net",
"overdrive", "strong", "fist", "padlock", "three-leaves", "fluffy-wing", "pummeled", "tread",
"arrowed", "aura", "back-pain", "black-flag", "bleeding-eye", "bolt-shield", "broken-heart", "cobweb",
"broken-shield", "flying-flag", "radioactive", "trophy", "broken-skull", "frozen-orb", "rolling-bomb", "white-tower",
"grab", "screaming", "grenade", "sentry-gun", "all-for-one", "angel-outfit", "archery-target"
*/
/**
* @module MarkStatus
*/
var MarkStatus = (function(ApiCommands){
var UsingCmdMsgProcessor = false;
// predefined Aura Colors, you can add more here
var AuraColors = {
"default": "#ff0000",
"red": "#ff0000",
"blue": "#0000ff",
"green": "#00ff00",
"yellow": "#ffff00",
"purple": "#9900ff",
"white": "#ffffff",
"black": "#000000",
"transparent": "transparent"
};
/**
* @class
* Contains script information
* name : Script Name
* version : script version
* desc : script descirption
*/
var scriptInfo = {
version : "1.1",
name : "MarkStatus",
desc : "Allows players to manage status markers via macros. Can add/remove/toggle/clear status markers for a specified token",
toString : function(){
var _ = ScriptInfo;
return _.name + " v" + _.version + "\n" + _.desc + "\n";
}
};
/**
* Registers a chat:message callback if UsingCmdProcessor = false
* If UsingCmdProcessor = true then the CmdMsgProcessor script will handle
* all chat commands for this script
*/
(function(){
if(!UsingCmdMsgProcessor){
log("Loading chat:message callback for " + scriptInfo.name);
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) ", "");
msg.Command = msg.content.split(" ", 1)[0];
if(msg.Command == "!addstatus" ||
msg.Command == "!remstatus" ||
msg.Command == "!togstatus" ||
msg.Command == "!clrstatus" ||
msg.Command == "!setaura") Process(msg);
})}})()
/**
* Main Process function which processes raw chat messages
* @param (msg) the raw chat message object recived from a chat:message callback
*/
Process = function(msg){
var args = _.rest(msg.content.split(" "));
var tokenIds = args.length >= 1 ? args[0].split(",") : "Invalid token_id";
var statusmarkers = args.length > 1 ? args[1].split(",") : undefined;
//log(msg.Command);
switch(msg.Command)
{
case "!clrstatus":
_.each(tokenIds,function(id){
ClearStatusMarkers(getObj("graphic", id), statusmarkers);
});
break;
case "!addstatus":
_.each(tokenIds,function(id){
AddStatusMarkers(getObj("graphic", id), statusmarkers);
});
break;
case "!remstatus":
_.each(tokenIds,function(id){
log(id);
RemStatusMarkers(getObj("graphic", id), statusmarkers);
});
break;
case "!togstatus":
_.each(tokenIds,function(id){
ToggleStatusMarkers(getObj("graphic", id), statusmarkers);
});
break;
case "!setaura":
var aura = args[1] || 1;
var radius = args[2] || "";
var color = args[3] || "transparent";
var isSquare = args[4] || "true";
_.each(tokenIds,function(id){
SetAura(getObj("graphic", id), aura, radius, color, isSquare);
});
break;
default:
//throw "Invalid command: " + msg.Command;
log("Invalid Command:"+msg.Command);
break;
}
}
/**
* Toggles a set of status markers for a given token
* @param (token) the token object returned from getObj("token", token_id);
* @param (statusmarkers) comma seperated list of status markers to toggle
*/
ToggleStatusMarkers = function(token, statusmarkers){
if(!token.get("statusmarkers")) token.set("statusmarkers", statusmarkers.join(","));
else{
_.each(statusmarkers, function(m){
token.set("status_"+m,!token.get("status_"+m));
});
};
};
/**
* Adds a set of status markers for a given token
* @param (token) the token object returned from getObj("token", token_id);
* @param (statusmarkers) comma seperated list of status markers to toggle
*/
AddStatusMarkers = function(token, statusmarkers){
_.each(statusmarkers, function(m){
token.set("status_"+m,true);
});
log("Status:" + token.get("statusmarkers"));
};
/**
* Removes a set of status markers for a given token
* @param (token) the token object returned from getObj("token", token_id);
* @param (statusmarkers) comma seperated list of status markers to toggle
*/
RemStatusMarkers = function(token, statusmarkers){
_.each(statusmarkers, function(m){
token.set("status_"+m,false);
});
log("Status:" + token.get("statusmarkers"));
};
/**
* Clears all status markers from the given token
* @param (token) the token object returned from getObj("token", token_id);
*/
ClearStatusMarkers = function(token){
token.set("statusmarkers", "");
log("Status:" + token.get("statusmarkers"));
};
SetAura = function(token, aura, radius, color, isSquare){
aura = aura == "aura1" ? aura : "aura2";
token.set(aura + "_radius", radius);
if(color.substr(0,1) != "#") color = AuraColors[color] || AuraColors["default"];
token.set(aura + "_color", color);
token.set(aura + "_square", isSquare.toLocaleLowerCase() == "true");
log(aura +" Change");
log("Radius: "+ token.get( aura+"_radius"));
log("Color: "+ token.get( aura+"_color"));
log("Square: "+ token.get( aura+"_square"));
}
ApiCommands["!addstatus"] = Process;
ApiCommands["!remstatus"] = Process;
ApiCommands["!togstatus"] = Process;
ApiCommands["!clrstatus"] = Process;
ApiCommands["!setaura"] = Process;
/*******************************************************
* Public Exports
******************************************************/
return {
addStatusMarkers : AddStatusMarkers,
toggleStatusMarkers : ToggleStatusMarkers,
remStatusMarkers : RemStatusMarkers,
clearStatusMarkers : ClearStatusMarkers,
process : Process,
scriptInfo : scriptInfo
}
})(ApiCommands);
Scripts["MarkStatus"] = MarkStatus;