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 .
×

Copying tokens

1399855028

Edited 1399855104
So just for the sake of it I was making a script to clone tokens from the Start page to my current page. Every time I ran my code I noticed only a few of the tokens got copied. This is the code I use to clone (pretty straight forward) var currentPageGraphics = findObjs({ _pageid: pageid, _type: "graphic", }); _.each(currentPageGraphics, function(obj) { //Do something with obj, which is in the current page and is a graphic. createObj("graphic", { name: obj.get("name"), controlledby: obj.get("controlledby"), left: obj.get("left")+70, top: obj.get("top"), width: obj.get("width"), height: obj.get("height"), bar1_value: obj.get("bar1_value"), bar1_max: obj.get("bar1_max"), showname: true, showplayers_name: true, showplayers_bar1: true, imgsrc: obj.get("imgsrc"), pageid: obj.get("pageid"), layer: "objects" }); }) } The script screen made it pretty clear why. "ERROR: You cannot set the imgsrc or avatar of an object unless you use an image that is in your Roll20 Library. See the API documentation for more info." After debugging a bit i found out that some of the tokens had a imgsrc with the max version of the image (eg. <a href="https://s3.amazonaws.com/files.d20.io/marketplace/5936/5F9eAvsLWF5GugRVkVH7Jg/max.png?1340053216" rel="nofollow">https://s3.amazonaws.com/files.d20.io/marketplace/5936/5F9eAvsLWF5GugRVkVH7Jg/max.png?1340053216</a> ) According to the API doc I should be using the thumb and the tokens that were getting copied all had the thumb.png version of the image. So I tried running a simple test. imgsrc: obj.get("imgsrc").replace("max", "thumb"), I debugged the result of this replace and it is the valid link to the thumb version of that image. But I still encounter the same error message. So now I am a bit lost on what else I could be trying since the final imgsrc that I am adding is a valid one and it appears to follow all the rules stated at the API doc.
Hi Felipe, I have encountered the same problem. I is actually functioning as intended. If the token has "/marketplace" in the URL then it will not work. You have to copy the URL of the image and then paste it into your browser to download the image. You then need to upload the image into your library and then use the image in your library for the token. It will then function properly using the API. Go to this page: <a href="https://wiki.roll20.net/API:Objects" rel="nofollow">https://wiki.roll20.net/API:Objects</a> And then read the section on the limitations of "imgsrc" when using the API.
I see that, but the two that are getting copied were never added to my lbrary and also have marketplace on their link