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

Anyone have a quick and easy script to create attributes?

I was wondering if anyone had a script to just create an attribute for all tokens selected on the fly. Doesn't need to give that attribute a value, just create it really.
No, but I could write one real quick if I were at home. :(
Gah, I'm sure Aaron gave me one before, ill try scrounging through the forums. Thanks for the gesture though HB :)
Home now. Will have one here in a  moment.
1458951025

Edited 1458952063
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.");         }     } });
1458951776

Edited 1458952092
Hrm... just thought of something, should it not create the attribute if it already exists? Added check for existing attribute to the above already.
Hah! Sweet this will come in handy! You're the best HB :)
Saevar L. "Liquid-Sonic" said: Hah! Sweet this will come in handy! You're the best HB :) +1