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

how do you get the graphic object data from the default token?

1594323008

Edited 1594323045
Angelo
API Scripter
Hi! when getting the default token through the&nbsp; character.get('defaulttoken', function(defaultToken) ... you receive something like this: {"width":140,"height":140,"light_radius":60,"bar1_value":"37","bar1_max":"37","bar2_link":"-M9dJRKM0C3XZunfAQYM","represents":"-M9dJP6PQWcjNXJrqGSW","name":"Tiger","imgsrc":"<a href="https://s3.amazonaws.com/files.d20.io/images/28451933/UmTtTMhdsGjrNZp6mAG0_w/thumb.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/28451933/UmTtTMhdsGjrNZp6mAG0_w/thumb.png</a>"} if you drop that character in the map and try to get the graphical obj you instead get a lot more info: {"_id":"-MAlqhSg7sDnujy2gpUr","_pageid":"7F73B956-71C3-4C5B-8C72-576EE4F15EA4","left":809,"top":209,"width":210,"height":210,"rotation":0,"layer":"objects","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"<a href="https://s3.amazonaws.com/files.d20.io/images/26793848/lrKQIeBPQaFni26FonosJQ/thumb.png&quot;,&quot;name&quot;:&quot;Adult" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/26793848/lrKQIeBPQaFni26FonosJQ/thumb.png","name":"Adult</a> Black Dragon","gmnotes":"","controlledby":"","bar1_value":"195","bar1_max":"195","bar1_link":"","bar2_value":19,"bar2_max":"","bar2_link":"-MAlqb5hLhIq0ju8lAkg","bar3_value":"","bar3_max":"","bar3_link":"","represents":"-MAlqahiwhtbVkqkKmCB","aura1_radius":0.63,"aura1_color":"#05ff00","aura1_square":false,"aura2_radius":"","aura2_color":"#59E594","aura2_square":false,"tint_color":"transparent","statusmarkers":"","showname":true,"showplayers_name":false,"showplayers_bar1":false,"showplayers_bar2":false,"showplayers_bar3":false,"showplayers_aura1":true,"showplayers_aura2":false,"playersedit_name":true,"playersedit_bar1":true,"playersedit_bar2":true,"playersedit_bar3":true,"playersedit_aura1":true,"playersedit_aura2":true,"light_radius":120,"light_dimradius":"","light_otherplayers":false,"light_hassight":false,"light_angle":"","light_losangle":"","light_multiplier":1,"adv_fow_view_distance":"","sides":"","currentSide":0,"lastmove":"805,209","_type":"graphic","_subtype":"token","_cardid":"","has_bright_light_vision":false,"has_night_vision":false,"night_vision_distance":0,"emits_bright_light":false,"bright_light_distance":0,"emits_low_light":false,"low_light_distance":0} I am not sure how the graphic object is created from the default token... my question is: is it possible from an API call to get/create all that data so that i can modify some fields and then call&nbsp;setDefaultTokenForCharacter with it?&nbsp;
1594323448
The Aaron
Roll20 Production Team
API Scripter
You would need to create a token with it first. Anything not in the defaulttoken JSON is either defaulted (like bar permissions) or supplied at creation time (like page ID and left, top).&nbsp; setDefaultTokenForCharacter() takes a token id, which means you must have a token somewhere for it to extract the data from.&nbsp;
1594324327
Angelo
API Scripter
can i create a graphic token in a random page, pass it to the setDefaultTokenForCharacter and then delete it in the same function?
1594327515
The Aaron
Roll20 Production Team
API Scripter
You can certainly try it. =D Worst case, you can set a timeout function to remove it.&nbsp; Also, you can create it off the page by using a negative left or top.&nbsp;
1594337377
Angelo
API Scripter
that worked fine, thank you!