Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] MarkStatus Manager

1400627896

Edited 1400712346
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;
Awesome script - Would it be terribly difficult to adapt this script to incorporate adding the ability to toggle off/on aura's as well? For example a runepriest casts a "rune of protection" effectively giving him/her an Aura 1sq/5ft, that gives adj allies damage reduction. the player hits the macro, the macro washes any previous aura, then applies the new aura. possible or am i just being silly?
1400708997

Edited 1400712764
Kenny T. said: Awesome script - Would it be terribly difficult to adapt this script to incorporate adding the ability to toggle off/on aura's as well? For example a runepriest casts a "rune of protection" effectively giving him/her an Aura 1sq/5ft, that gives adj allies damage reduction. the player hits the macro, the macro washes any previous aura, then applies the new aura. possible or am i just being silly? That should be quite doable. I'll update it tonight with the change. Updated script to v1.1 Now has !setaura command !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 There are a number of predefined colors available. You can easily add your own by adding them to the AuraColors variable near the top of the script. Naturally you don't have to use the predefined colors, you can specify any RGB value you wish. The predefined colors were added to make it easy for the most common colors. If you have any issues at all, or for any reason the script cases your API sandbox to crash, just post the API error message with the command that caused the error here and i'll be sure to update the script. I have tested as much as I can to ensure the script won't crash the API sandbox, but I've found general users are just way better than me at finding problems.
Great work! So I am trying to figure out the best way to implement this. I am trying to find a way for it to come up after a power card is shown, so that if saves are failed the status can be changed. It would be nice if it posted a button-like item to the chat window so that the status can be toggled back off again when the effect ends. Do you have any suggestions? Here is what I have. The problem is it asks to toggle status before the card posts. !power --desc| --name|@{selected|token_name } --txcolor|#FFF --bgcolor|#990000 --S1-Charm-Person|R30' (humanoid); D 1h; [[8@{Spells}]]WS (AD if fighting) or charmed (end if you/ally act harmful); H +1 target in 30' other targets/lv !togstatus @{target|t1|token_id} broken-heart
1400900628

Edited 1400900751
Nice Chris! Works Beautifully! Thanks for putting this together! You've made my runepriest a very happy camper! Finding a bunch of cool ways to use this.
Thomas C. said: Great work! So I am trying to figure out the best way to implement this. I am trying to find a way for it to come up after a power card is shown, so that if saves are failed the status can be changed. It would be nice if it posted a button-like item to the chat window so that the status can be toggled back off again when the effect ends. Do you have any suggestions? Here is what I have. The problem is it asks to toggle status before the card posts. !power --desc| --name|@{selected|token_name } --txcolor|#FFF --bgcolor|#990000 --S1-Charm-Person|R30' (humanoid); D 1h; [[8@{Spells}]]WS (AD if fighting) or charmed (end if you/ally act harmful); H +1 target in 30' other targets/lv !togstatus @{target|t1|token_id} broken-heart Allowing buttons or other gui interfaces from api: At the moment there isn't any way to accomplish this as you suggest. The best alternative is to have a separate macro that does the status changes when you need it. There is however, another script made by another than can keep track of timed status effects and automatically remove them when they expire. I had a little trouble with it so I have abandoned it, but if you're interested here it is. <a href="https://app.roll20.net/forum/post/197725/script-co" rel="nofollow">https://app.roll20.net/forum/post/197725/script-co</a>... I'm not sure if the author is still maintaining it, but if you're interested, it never hurts to ask. Why does the target interface come up before the power card is displayed? In regards to the toggle status before the card posts. This is due to @{target|token_id}, The roll20 message processor attempts to expand first and requires the the targeting function to kick off before the api is executed. However, I would still expect that the !power card command should occur first before the !togstatus is executed. Question: Looking at your !power command, I see that you have @{selected|token_name}, Am I assuming correctly that you are selecting your token before you press the macro, then you click the enemy token when the target (crosshair) comes up?
Chris N. you are correct. I have done just what you suggested and made separate macros. It is working great. Looking forward to our game today. Thank you for creating this macro. Is there a way to target multiple tokens but without knowing the number beforehand?
Thomas C. said: Chris N. you are correct. I have done just what you suggested and made separate macros. It is working great. Looking forward to our game today. Thank you for creating this macro. Is there a way to target multiple tokens but without knowing the number beforehand? The only way to do something such as that would be to use the selected tokens as the targets. This would require a macro update however. Essentially, you would select a group of tokens then press the macro, and the effect could be applied to all of them. In terms of using the target functionality, I see no way to do this. Is the target by multi selection something you would want to have?