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

createObj with imgsrc, getting error that image is not in my library

1521462191

Edited 1521463009
Trying to create a couple of tokens for a script I will release soon. problem is that I get the error: "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." I have uploaded three images to my library that I am using as placeholders. (a red square)&nbsp; <a href="https://s3.amazonaws.com/files.d20.io/images/50183" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/50183</a>... (a grey square)&nbsp; <a href="https://s3.amazonaws.com/files.d20.io/images/50183" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/50183</a>... (a transparent png) <a href="https://s3.amazonaws.com/files.d20.io/images/38361" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/38361</a>... I have read the API instructions about imgsrc restrictions. I think I am using valid links. these files have been uploaded to my library. I found the links by dragging te tokens from my roll20 image library to the page grid, then pressing Z and copying the image adress from the zoomed-in token. sometimes one of the tokens is created but not the rest. I even set delays in my code to avoid all the token objects being created at the same time. all to no avail, it just inconsistently gives me the error message above. I want these images to be available to all players that use my script btw - as an example,&nbsp; TrackerJacker script does this (there is a graphic that is created around the player token, that has to be from an imgsrc link.) Here is the code snippet that I use to create the tokens: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout(function() { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Gryphon&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var testToken1 = createObj("graphic", { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _subtype: "token", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _pageid: Campaign.get("playerpageid"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; represents: AuxObj.get("_id"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Scenario Switcher: Scenario with Gryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showname: true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imgsrc: "<a href="https://s3.amazonaws.com/files.d20.io/images/50183580/M926JFbiBvBbEfWc9-i3Zg/thumb.png?15214606025" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/50183580/M926JFbiBvBbEfWc9-i3Zg/thumb.png?15214606025</a>", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusmarkers: "dead, spanner", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: "walls", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_value: "Gryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_max: "A Gryphon attacks ,Gryphon| No attack happens ,NoGryphon| image description 3 ,-| image description 4 ,-| image description 5 ,-", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gmnotes: "", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log(testToken1); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, 1*1000); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout(function() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var testToken2 = createObj("graphic", { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _subtype: "token", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _pageid: Campaign.get("playerpageid"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; represents: AuxObj.get("_id"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Gryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showname: true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imgsrc: "<a href="https://s3.amazonaws.com/files.d20.io/images/38361589/Ip65dur3Rhylowaxv0-qTw/thumb.png?15040768025" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/38361589/Ip65dur3Rhylowaxv0-qTw/thumb.png?15040768025</a>", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: 140, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: 140, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusmarkers: "dead, fluffy-wing", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: "walls", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_value: "Gryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_max: "A Gryphon attacks ,Gryphon| No attack happens ,NoGryphon| image description 3 ,-| image description 4 ,-| image description 5 ,-", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gmnotes: "object_layer", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log(testToken2); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, 2*1000); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //No Gryphon&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var testToken3 = createObj("graphic", { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _subtype: "token", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _pageid: Campaign.get("playerpageid"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; represents: AuxObj.get("_id"), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Scenario Switcher: Scenario without Gryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showname: true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imgsrc: "<a href="https://s3.amazonaws.com/files.d20.io/images/50183581/8jh_JYEAhYffVfBguqtt0A/thumb.png?15214606025" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/50183581/8jh_JYEAhYffVfBguqtt0A/thumb.png?15214606025</a>", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 70, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusmarkers: "dead, spanner", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: "walls", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_value: "NoGryphon", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar1_max: "A Gryphon attacks ,Gryphon| No attack happens ,NoGryphon| image description 3 ,-| image description 4 ,-| image description 5 ,-", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gmnotes: "", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log(testToken3);
1521476859
GiGs
Pro
Sheet Author
API Scripter
Are these tokens linked to a character with a blank avatar? You can get this error whenever you are changing the graphic properties of a character who has no avatar. In this case, its a harmless error and can be safely ignored.&nbsp;
1521479049

Edited 1521479171
one of them is, yes! thanks for the input :) would this script work for others too? I understood it like this: as long as the pictures are in my library others can also access them via this script.
1521479781
The Aaron
Pro
API Scripter
Yes, it would work for others.
thank you! :)