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

No way to get filename of base asset from library?

1568964260

Edited 1568964518
I'm trying to cobble together a script to do some automatic resizing on the 'add:graphic' event based on the name of a graphic's library filename. Is there absolutely no way to get the library filename of a map tile from an 'Object' (roll20, not js) object? If I have to put together a dictionary of s3 URLs to desired dimensions I'm going to scream.
1568981124
The Aaron
Roll20 Production Team
API Scripter
Prepare your neighbors with earplugs... ...nope, there's no way to do that in the API. 
Lmao that's super frustrating. Is it just overlooked, or was it some sort of "design decision"?
1569015960
The Aaron
Roll20 Production Team
API Scripter
Hard to say. I speculate it was not foreseen as a desirable feature. What problem are you trying to solve?  Is it literally getting a mapping from url to name so you can name things, or does the name contain some sort of information of interest to your script?
The root problem I am facing is that roll20 defaults an image to a version that is capped at 200px (height or width, whichever is bigger) when first dropping it onto the VTT. I would much prefer it to simply let me use the image's default resolution instead of using a smaller version (the main issue here is that this completely messes up the individual grid sizes between assets in an asset pack when trying to stitch them together). Me appending the image's native resolutions to the end of their name (python) was me thinking the roll20 script engine would pass me the base asset name to my callback so then I could parse out the dimensions and resize as part of the 'add:graphic' callback. I've also tried running my own snippets in Chrome to parse out the base asset name which is then stored in the global Window object on the 'mousedown' event with the intent that the 'add:graphic' event would be able to access Window, but that does not appear to be the case either unfortunately.  In what context does the roll20 scripting engine execute? Does it not execute in the same javascript environment and browser tab I'm currently running a game in? That could be part of my confusion for my 2nd method, because what I would need is a global object accessible by both contexts for this to work. At any rate, I've since bitten the bullet and moved on to just putting maps together from the asset pack using Gimp.
1569468466
The Aaron
Roll20 Production Team
API Scripter
The API runs in a sandbox on a server in the cloud. It must be that way in order to server all players and for when the GM is not signed in. You can think of it as an extra player connected to the game. The sandbox is running under Node. I don't recall the precise version (but it's the one where the spread operator worked for Arrays, but not yet for Objects). It doesn't have access to your browser. 
1569472856

Edited 1569472887
Gotcha, that makes sense. Would you know how the body of this code: ```     on("add:graphic", function(obj) {         obj.set({             width: 200,             height: 1000,         });     }); ``` actually communicates to the browser its intent of resizing the passed object to 200x1000? I didn't see anything interesting in Network (was hoping I might see something interesting in WS). I also thought they may just send a png scaled to those dimensions but that did not appear to be the case either.
Just wanted to be sure you saw this: <a href="https://app.roll20.net/forum/permalink/7752818/" rel="nofollow">https://app.roll20.net/forum/permalink/7752818/</a> No date yet, and it looks like it is just for Marketplace creators now, but it may be a system that regular users can take advantage of for items in their Art Library. That's my hope at least. If nothing else, if you are writing this just for Marketplace assets and not personal ones, you can probably hold off. :-)
1569498221

Edited 1569498285
The Aaron
Roll20 Production Team
API Scripter
All Roll20 objects exist as data records in Firebase, a near real-time object database. The API reacts to events describing a change in the state of Firebase objects (basically), and itself changes the state of those objects. Firebase synchronizes the state of those objects among all the connected clients. You move an object, that object's change in location is communicated to all connected clients (one of which is the API). The API sees that change in the object and does something as a result, etc.
Thanks Aaron, that makes sense. I am still curious as to why I see nothing in the network tab (perhaps I need to check it from the viewpoint of another player receiving the updates), but it's probably about time I spend some time learning about Firebase anyway.
1570069304
The Aaron
Roll20 Production Team
API Scripter
The network tab shows http traffic, connections to port 80 or 443 to get or send file data. That's too slow for a near real-time database. I'm sure Firebase is connecting via a websocket. You can probably find the source http connection and upgrade request if you dig for it, but I don't know of a built in way to snoop the traffic like you can with http/AJAX sorts of things, and it probably wouldn't be all that useful.&nbsp;