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

Is it possible to identify a map's directory structure via API?

I'm attempting to organize my map pages by location.  For instance Northern/Coastal/Marina.  I then want to gather that data and store it (ultimately to build random encounter tables, etc).  However, the best I can get is the map page's name and ID.  Here's my latest attempt: /* ========================================================================== */ /* ACTIVE PAGE METADATA CAPTURE */ /* ========================================================================== */ /** * Returns the Page object currently active for the calling player. * If the player has a player-specific page, that page is returned; * otherwise the campaign’s global player bookmark is used. */ function getActivePageForPlayer(playerId) { var campaign = Campaign(); var specific = campaign.get('playerspecificpages'); var pageId = null; if (specific && typeof specific === 'object' && specific[playerId]) { pageId = specific[playerId]; } else { pageId = campaign.get('playerpageid'); } if (!pageId) return null; return getObj('page', pageId) || null; } /** * Collects the unique Roll20 page ID and its name as displayed in the UI. */ function collectPageMeta(page) { return { id: page.id, name: page.get('name') || '' }; } /** * Captures and returns metadata for the page currently active * for the given player ID. */ function captureForPlayer(pid) { var page = getActivePageForPlayer(pid); if (!page) { return { error: 'Could not resolve an active page for you.' }; } var meta = collectPageMeta(page); return { meta: meta }; } which gives output similar to: Map Information Page:  Marina  (-OdYtrXRlCu8O6qq36Ub) But what Im attempting to collect is: Map Information Page:  Marina  (-OdYtrXRlCu8O6qq36Ub) Region: Northern Locale: Coastal As best as I can tell, the map directory structure isnt exposed to the API, but I'm really hoping that I am wrong and there is some cool way to get this done.  Im a failure, but Im willing to learn.  :) Thanks in advance for any assistance you can give.  It is greatly appreciated. peaces! ~tcm
1762640507
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi TCM! AFAIK, the page folder structure is not exposed to the API, but there are still some possibilities. For example. you could store map metadata on the map image. It has all of the bars, names and fields of a token. Thus you could store region on bar 1, climate on bar 2, etc. A script could then be written to look through all pages and build its metadata from those images. This would be easier if all map images could be set to represent a single character, called "Map" for instance. The script could search the campaign for any graphic representing that character.
thanks for the quick reply, @keithcurtis.  appreciated! I added a quick: on('ready', () => log('pageorder = ' + Campaign().get('pageorder'))); to the script, sandbox returns: "pageorder = undefined" so, im afraid I have to agree with you.  I like your idea on bar 1, 2 and 3 on the map image.  That's a clean alternative.  I am currently exploring x.y.z (region.locale.map) page naming conventions to achieve the same end-result.  Its probably gonna work, but not nearly as elegant. tnx again. ~tcm