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

[Generating master handouts] is it possible to filter on tags or directory ?

Hello, I created several handout (1 for each spell my players knows). I organised them with tags like mage0 for all level 0 for wizzard. I orignally planned to create a master handout linking all spells but because I'm quit lazy I would like to generate it :) But I haven't found in the API documentation how the tags are managed... Anyone know how I can filter them using tags ? If not possible is it possible to get the directory tree in the api ?
1599768335
timmaugh
Pro
API Scripter
Sadly, I don't think either of those things are exposed to the API. I hope I'm wrong, I was looking to something with the tags myself.
1599769465
The Aaron
Roll20 Production Team
API Scripter
Tags are definitely not exposed. The folder structure is accessible via the Campaign object's _journalfolder property, which contains a JSON encoded object representing all the folders and their contents.
ok I also had this feeling for the tags :/ Maybe oneday it will be accessible throuh API, until then I think I will be able to generate it with the journal folder. I guess "i" means items in the directory (id array) and "n" means directory's name
1599775709

Edited 1599836425
The Aaron
Roll20 Production Team
API Scripter
Yup!  If it helps, here's a function that builds a lookup by id for the path where a handout or character is stored: const pathSep = " -> "; const buildLookup = (data) => { const dataTree=JSON.parse(data||'{}'); const lookup = {}; const treeBuilder = (obj,path) => { obj.forEach((n) => { if(_.isString(n)){ let p = [...path]; p.reduce((m,a)=>{ m.push(a); let curPathKey = m.join(pathSep); lookup[curPathKey]= (lookup[curPathKey]||[]); lookup[curPathKey].push(n); return m; },[]); } else { path.push(n.n); treeBuilder(n.i,path); path.pop(); } }); }; treeBuilder(dataTree,[]); return lookup; }; Can be called like: let locationLookup=buildLookup(Campaign().get('journalfolder'));
Always a shock when seing your code, seems I lack the javascript way. With your function it will be so much easier to just proceed with a json parse. Thanks Aaron PS : if someone else want to use in the future just initialise  pathSep  with the serator you want
1599836409
The Aaron
Roll20 Production Team
API Scripter
Ah, good point on the pathSep.  I added something above just to make it easier on peeps. I also lacked the Javascript way when I started writing API scripts. =D  Just time, practice, and research.