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

Modify Token Default Options

Is it possible to change the default options for a Generic Token inserted from the Art Library?  What I mean is this:

When I add a token from the Art Library, it's default properties are such that it does not represent a character, it's name is blank, and it can be controlled only by the GM.  I would like any monster token added to the map to be controllable by the players.  In particular I would like my players to be able to move the tokens around the board, and apply/remove marks of various colors.  I ask because the defender in my party (D&D 4e) often marks and slides enemies, and it would be very convenient if he could do that on screen himself rather than using the ruler to point which token he wants me to move and to where.  

I know that I can individually set each token's properties to allow player control, but this is slow for the players and tedious for the GM.  Is it possible to change the default settings?  Perhaps I can create a macro that I run at the start of each session to change the defaults?

Thanks in advance for any help,
Dan N.

May 21 (12 years ago)
Gid
Roll20 Team

If you create character sheets for your monsters in the journal tab, setup their permissions so that the players can manage them, and link tokens to them. Then any time that character sheet is dragged from the journal tab to the tabletop, a token will be created with the same permissions assigned to the journal entry.

Well that requires you to set up journal entries for every different token etc, which is probably not what you wanna do.

What you can do however is make a journal entry "!! NPC" or so (the !! is so that it shows up first). Give the defender edit rights etc on it, as well as anyone else you like to be able to operate the token.

Then when you drag a new item to the table, double click it and set it to "Represents !!NPC" or however that is called. Now the token automatically is controlable by anyone assigned to the sheet. Make sure to NOT link any of the 3 bars to a stat on the character sheet, otherwise that gets shared between all of them. If you don't link them, each of them gets their own separate bars.

Unfortunately it gets also named !! NPC then, but there's nothing you can do except change it manually. There's also no way that I know that brings the token into the world and not snapping and resizing to a 1x1 grid right away. Except if there's no grid when you add them, then they should be added correctly sized.

May 21 (12 years ago)
Konrad J.
Pro
API Scripter

Dan N. said:

Is it possible to change the default options for a Generic Token inserted from the Art Library?  What I mean is this:

When I add a token from the Art Library, it's default properties are such that it does not represent a character, it's name is blank, and it can be controlled only by the GM.  I would like any monster token added to the map to be controllable by the players.  In particular I would like my players to be able to move the tokens around the board, and apply/remove marks of various colors.  I ask because the defender in my party (D&D 4e) often marks and slides enemies, and it would be very convenient if he could do that on screen himself rather than using the ruler to point which token he wants me to move and to where.  

I know that I can individually set each token's properties to allow player control, but this is slow for the players and tedious for the GM.  Is it possible to change the default settings?  Perhaps I can create a macro that I run at the start of each session to change the defaults?

Thanks in advance for any help,
Dan N.

Hmmm, yet another good idea for a possible API script. There is an add graphic event that fires.  I never tried it, but it should work.  We can change most properties of an object.  I'll whip one up if I get a chance in the next few days.  I never though of this, but it could be useful for setting defaults, each GM can set different defaults that way.
PS: the only problem being you have to be a mentor to use scripts. :(  But I'll still work a script up and see how useful it is.  You can set bars to be visible, not visible, aura's on/off, etc all as the default.

Konrad J. said:

Hmmm, yet another good idea for a possible API script. There is an add graphic event that fires.  I never tried it, but it should work.  We can change most properties of an object.  I'll whip one up if I get a chance in the next few days.  I never though of this, but it could be useful for setting defaults, each GM can set different defaults that way.
PS: the only problem being you have to be a mentor to use scripts. :(  But I'll still work a script up and see how useful it is.  You can set cars to be visible, not visible, aura's on/off, etc all as the default.
Thanks all for the help and advice.  Konrad J, I think you are right that it would be a useful feature that GM's can save "Default" settings within their own campaigns.  I look forward to hearing how it works.

May 22 (12 years ago)
Konrad J.
Pro
API Scripter

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);

});

});


Awesome response Konrad, thanks for the help.  I look forward to trying this out.

May 23 (12 years ago)
Konrad J.
Pro
API Scripter

Dan N. said:

Awesome response Konrad, thanks for the help.  I look forward to trying this out.

Thanks, it seems to work great and helps with one thing that bugged me.  Every time I added a new token I'd have to go and edit it, give access to all players, see bars, etc.  Now you can set the defaults to your personal tastes.

You are going to have to go mentor for at least a month though to try it out I think. :(

I'm working on a script that has all of my Roll20 "improvements". :)  It has my graphic defaults, rotation lock, size lock, stop watch/timer, and time stamp scripts.  I'm just working on finishing a new one that tells you how many units you have moved and puts a token where you just moved from.

I can't release this big one until I've got documentation done since there are three or four things the GM needs to do with tokens and setup before they will work properly.  Also need to document all the commands properly so users know how to use it.  My movement tracking script I really like, works awesome.  Got a few more things to add to it though.