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

Bug: API function createObj() imgsrc/avatar error messages

When using the createObj() call in an API script to create any of the objects with an 'imgsrc' or 'avatar' attribute it logs the following error if you do not set the imgsrc/avatar attribute:  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. While I can understand this could be a legitmate error when creating the graphic object, I still consider this is a bug because creating an object using the default values for the optional attributes of said object shouldn't throw an error. These error messages clutter the log and make it difficult to spot legitimate errors. the following test function can be used to recreate the issue: function test_createObj_bug(){ /** the error message being logged makes sense here when creating an object of type:graphic, but it would make more sense to make imgsrc a required field for the object, like how pageid is a required field to create the object. **/ var pageId = Campaign().get('playerpageid'); log('Creating a Graphic object with default settings.'); createObj('graphic',{pageid:pageId,name:'test_graphic',layer:'objects'}); /** the error message being logged doesn't make sense for these calls since the imgsrc/avatar attribute is optional and defaults to an empty string **/ log('Creating a Character object with default settings.'); createObj('character',{name:'test_character'}); log('Creating a Handout object with default settings.'); createObj('handout',{name:'test_handout'}); var table = createObj('rollabletable',{name:'test_table'}) log('Creating a Table Item object with default settings.');  createObj('tableitem',{rollabletableid:table.get('id'),name:'test_tableitem'}); } Executing that code generates this log:
As a workaround, when you create the new object that has an image field, does setting that field to a blank string "" prevent the error?