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

Updating Default Token from API - How?

1561220126

Edited 1561221796
GM Michael
API Scripter
I'm working on an API script that scale characters (their health, damage, etc) up and down, and reached the point where I was trying to update the default token, but _defaulttoken is a read-only field.  Is there not any way to do this from the API? The Roll20 Enhancement Suite is a chrome extension that can do this, so I have to imagine there is a  way, but poking araound that extension didn't immediately reveal anything, though granted I'm not terribly familiar with typescript. Update: upon further inspection, it looks like R20ES calls the same webpage function as actually installing a new default token, so I don't believe that's an option after all.
1561221293
The Aaron
Roll20 Production Team
API Scripter
You use the setDefaultTokenForCharacter( characterObject, tokenObject ) function: setDefaultTokenForCharacter(repChar,token); Note that there is bug right now where the token bars preferences don't get saved.
Thanks!
1561221991
The Aaron
Roll20 Production Team
API Scripter
Note that you're passing the Character Object, not the character ID.&nbsp; And the Token Object.&nbsp; Here's the original announcement for the function:&nbsp; <a href="https://app.roll20.net/forum/permalink/3862777/" rel="nofollow">https://app.roll20.net/forum/permalink/3862777/</a>