OK, here it is. Its one of the simplest scripts I've written. Not much too it. Whenever a token is dragged onto the map the script sets all its properties to what you define in the script's global variables. Just read the comments on each line to get an idea on what to put where. Its actually going to be a very useful little script for me. If you always end up changing the default values on tokens then this will be a great time saver for you.
You can do things like set the default controlledby to "all", set the default bar edit properties, or even set the default layer to "gm"?
To make it even better I would add chat window commands so you can change the defaults without having to go to the API editor and change the global variables. Then I would add the global variable to the state variable which means it would save the defaults from campaign session to session. So when you close and reopen a campaign it will remember all the defaults you set.
Please be very careful. Please use it on a copy of your campaign at first. I've tested it fairly well and there shouldn't be any problems, but I can't guarantee it. One problem I found is if you let the layer get set to "" the campaign goes all blank white screen. :) So I put some protections against that. If you leave it at "" then it lets Roll20 set the layer to the layer you are currently on. Same with the x,y coordinates of the token, and the height and width of the token.
Here is the script. Once I add the two options I mentioned above I'll post it on Github and in the API section of the forum.
To use it you simply copy everything below here to one of your script tabs in the API editor. Save it and then test it out.
Please feel free to ask me any questions.
Dan N. For the script to do what you originally asked all you need to do is controlledby from "" to "all". Then anyone can do anything to the token. Just remember to manually change any tokens you only want the GM to control by editing the token after dropping it on the table. :)
var graphicGlobal = {
left: 0, // I wouldn't change Top or Left unless you want all new tokens to come onto the board always in a certain area?
top: 0, // Otherwise Roll20 sets these two values to approx where you drop them on the map which is probably how you want it usually
width: 0, //size in pixels. usually 70 pixels is one unit
height: 0, // if you leave these values at zero then Roll20 will decide on the size depending upon if there is a grid enabled or not.
rotation: 0.0,
layer: "", // "", "gmlayer", "map", or "objects". If you set it to "" then the layer Roll20 is currently on is what is used.
isdrawing: false, //advanced -> is drawing?
flipv: false, //flip vertically
fliph: false, //flip horizontally
name: "", //Token Name
gmnotes: "", //GM Notes
controlledby: "", // "" or "all"
bar1_value: "", //Current value of Bar 1 (number OR text)
bar1_max: "", //Max value of Bar 1
bar2_value: "",
bar2_max: "",
bar3_value: "",
bar3_max: "",
aura1_radius: "", //Radius (integer or float) of the aura. Set to empty string ("") for none.
aura1_color: "#FFFF99", //HEX color
aura1_square: false, //Is the aura square?
aura2_radius: "",
aura2_color: "#59E594",
aura2_square: false,
tint_color: "transparent", //HEX color or "transparent"
status_redmarker: false, //show the red marker on the token
status_bluemarker: false,
status_greenmarker: false,
status_brownmarker: false,
status_purplemarker: false,
status_dead: false,
showname: false, //show the nameplate
showplayers_name: false, //show the name to all players
showplayers_bar1: false,
showplayers_bar2: false,
showplayers_bar3: false,
showplayers_aura1: false,
showplayers_aura2: false,
playersedit_name: false, // allow controlling players to edit the name. also show the name to controlling players even if showplayers_name is false
playersedit_bar1: false,
playersedit_bar2: false,
playersedit_bar3: false,
playersedit_aura1: false,
playersedit_aura2: false,
light_radius: "", //dynamic lighting radius
light_dimradius: "", //dim radius
light_otherplayers: false, //show light to all players
};
on("ready", function() {
on("add:graphic", function(obj) {
if (graphicGlobal.left != 0) {
obj.set("left", graphicGlobal.left);
}
if (graphicGlobal.top != 0) {
obj.set("top", graphicGlobal.top);
}
if (graphicGlobal.width != 0) {
obj.set("width", graphicGlobal.width);
}
if (graphicGlobal.height != 0) {
obj.set("height", graphicGlobal.height);
}
obj.set("rotation", graphicGlobal.rotation);
if (graphicGlobal.layer != "") {
obj.set("layer", graphicGlobal.layer);
}
obj.set("isdrawing", graphicGlobal.isdrawing);
obj.set("flipv", graphicGlobal.flipv);
obj.set("fliph", graphicGlobal.fliph);
obj.set("name", graphicGlobal.name);
obj.set("gmnotes", graphicGlobal.gmnotes);
obj.set("controlledby", graphicGlobal.controlledby);
obj.set("bar1_value", graphicGlobal.bar1_value);
obj.set("bar1_max", graphicGlobal.bar1_max);
obj.set("bar2_value", graphicGlobal.bar2_value);
obj.set("bar2_max", graphicGlobal.bar2_max);
obj.set("bar3_value", graphicGlobal.bar3_value);
obj.set("bar3_max", graphicGlobal.bar3_max);
obj.set("aura1_radius", graphicGlobal.aura1_radius);
obj.set("aura1_color", graphicGlobal.aura1_color);
obj.set("aura1_square", graphicGlobal.aura1_square);
obj.set("aura2_radius", graphicGlobal.aura2_radius);
obj.set("aura2_color", graphicGlobal.aura2_color);
obj.set("aura2_square", graphicGlobal.aura2_square);
obj.set("tint_color", graphicGlobal.tint_color);
obj.set("status_redmarker", graphicGlobal.status_redmarker);
obj.set("status_bluemarker", graphicGlobal.status_bluemarker);
obj.set("status_greenmarker", graphicGlobal.status_greenmarker);
obj.set("status_brownmarker", graphicGlobal.status_brownmarker);
obj.set("status_purplemarker", graphicGlobal.status_purplemarker);
obj.set("status_dead", graphicGlobal.status_dead);
obj.set("showname", graphicGlobal.showname);
obj.set("showplayers_name", graphicGlobal.showplayers_name);
obj.set("showplayers_bar1", graphicGlobal.showplayers_bar1);
obj.set("showplayers_bar2", graphicGlobal.showplayers_bar2);
obj.set("showplayers_bar3", graphicGlobal.showplayers_bar3);
obj.set("showplayers_aura1", graphicGlobal.showplayers_aura1);
obj.set("showplayers_aura2", graphicGlobal.showplayers_aura2);
obj.set("playersedit_name", graphicGlobal.playersedit_name);
obj.set("playersedit_bar1", graphicGlobal.playersedit_bar1);
obj.set("playersedit_bar2", graphicGlobal.playersedit_bar2);
obj.set("playersedit_bar3", graphicGlobal.playersedit_bar3);
obj.set("playersedit_aura1", graphicGlobal.playersedit_aura1);
obj.set("playersedit_aura2", graphicGlobal.playersedit_aura2);
obj.set("light_radius", graphicGlobal.light_radius);
obj.set("light_dimradius", graphicGlobal.light_dimradius);
obj.set("light_otherplayers", graphicGlobal.light_otherplayers);
});
});