Programmatic Creation of Adventures?

I am working on a macro/module to split a large adventure (over 60 scenes, 700 characters) into individual adventures. I have 90% of the macro written, except for the final step of moving the scene and character folders I create into compendium adventures. I have been looking through the API docs, and I see that there is a BaseAdventure document, but I am a bit lost on the way to structure the data to create the object and put it into the correct compendium. Any advice on how to do this? This is what I have so far, but the adventure is empty:
for (const [key, f] of Object.entries(folders)) {
console.log('Creating adventure ' + key);
console.log(f);
console.log(f.actors);
let folder_arr = [f.actor_folder, f.scene_folder];
console.log(folder_arr);
data = {
name: key,
img: '',
caption: 'No image provided',
description: 'Sub-Adventure',
actors: f.actors,
scenes: f.scenes,
folders: [], // TODO: Add
sort: 1,
flags: {}
}
let created = await Adventure.create([data], {pack: "world.coto-optimized-adventures"});
console.log(created);
}
for (const [key, f] of Object.entries(folders)) {
console.log('Creating adventure ' + key);
console.log(f);
console.log(f.actors);
let folder_arr = [f.actor_folder, f.scene_folder];
console.log(folder_arr);
data = {
name: key,
img: '',
caption: 'No image provided',
description: 'Sub-Adventure',
actors: f.actors,
scenes: f.scenes,
folders: [], // TODO: Add
sort: 1,
flags: {}
}
let created = await Adventure.create([data], {pack: "world.coto-optimized-adventures"});
console.log(created);
}
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?