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

[Request] Set Token Defaults whenever a new token is created

I posted this as a suggestion to add to the Campaign Settings in Roll20, and someone mentioned this could be accomplished with the API. I tried playing with it a little but I haven't been able to achieve the desired effect. In my campaigns, I find I have to manually adjust the defaults for newly created tokens every time I create a new token, and when I forget it can take a long time to fix. This is less of an issue with Journal entries which can be copied and edited, but once a token image is selected, the image can't be changed. For example, all my tokens have a displayed nameplate, an aura 0 with a color indicating friend or foe and a basic light radius. I'd like to be able create defaults settings so that for every newly generated token: - Show nameplate is always checked - One or both auras are automatically set up - Player Permissions checkbox defaults--I always want players to see my token names and auras - Default Light radius setting along with Sight/All Players checkbox That I can then adjust after the token is created. Can someone help with this? Thank you!
1404241115
Lithl
Pro
Sheet Author
API Scripter
Basically, this is just a matter of setting some properties in a create:graphic event. on('create:graphic', function(obj) { if (obj.get('subtype') != 'token') return; // don't set properties on cards obj.set({ showname: true, showplayers_name: true, aura1_radius: 0, aura1_color: '#8888ff', // Change to whatever default color you like showplayers_aura1: true, light_radius: 40, // Change to preferred radius light_dimradius: 30, // Change to preferred dim radius light_otherplayers: true, light_has_sight: true }); }); I think that covers all the properties you're looking for. You can see a listing of all of the properties of graphics objects on the wiki .
Brian said: Basically, this is just a matter of setting some properties in a create:graphic event. on('create:graphic', function(obj) { if (obj.get('subtype') != 'token') return; // don't set properties on cards obj.set({ showname: true, showplayers_name: true, aura1_radius: 0, aura1_color: '#8888ff', // Change to whatever default color you like showplayers_aura1: true, light_radius: 40, // Change to preferred radius light_dimradius: 30, // Change to preferred dim radius light_otherplayers: true, light_has_sight: true }); }); I think that covers all the properties you're looking for. You can see a listing of all of the properties of graphics objects on the wiki . You rock, thank you!
1404264705
The Aaron
Roll20 Production Team
API Scripter
Brian is my forum lurker idol! =D
I copied and pasted your script but it doesn't seem to be doing anything . . . Was that just a chunk or is that the whole script? (I did modify it but I don't believe I did anything that would stop it from working.) on('create:graphic', function(obj) { if (obj.get('subtype') != 'token') return; // don't set properties on cards obj.set({ showname: true, showplayers_name: true, showplayers_bar1: true, showplayers_bar2: true, showplayers_bar3: true, }); }); (Copying and pasting is eliminating my formatting. I'm not sure how you get your code to appear in the box.) Thanks in advance!
1404591843

Edited 1404593740
The Aaron
Roll20 Production Team
API Scripter
Glospey, you select the block of code and click the paragraph symbol ( ¶ ) in the upper left corner, then choose code . Looks like it should be "add:graphic". Also, I wrapped it in on('ready',...) so it doesn't get called for all the graphics added each time you load a page.: on('ready',function(){ on('add:graphic', function(obj) { if (obj.get('subtype') !== 'token') return; // don't set properties on cards obj.set({ showname: true, showplayers_name: true, showplayers_bar1: true, showplayers_bar2: true, showplayers_bar3: true, }); }); });
Awesome! That's perfect! Thank you!
1404593749
The Aaron
Roll20 Production Team
API Scripter
Happy to help! =D