#Importing just one scene of an Adventure
1 messages ยท Page 1 of 1 (latest)
Let's do this in a thread so we're not stepping on other people's discussion
I don't visit this channel often, but it looked like Zhell was helping someone else so this will help organize it
Appreciate it.
It'll probably take me 5-10 minutes. Gonna install an adventure module that I own and test this out
Looks like we can have the macro use a hook to intercept some of the data preparation. Basically I'll tell the import code to ignore any updates, that way it'll only create new things
hopefully for you that means creating the scene
Appreciate you. Got like 100 hours of homebrew baked into my instance of the world.
My brain does not process code at all I struggle with CSS, so you're speaking greek to me, but I appreciate it.
(This thread title is unfortunate lmao)
In fairness, I've been a professional software dev for over a decade and CSS still trips me up sometimes, it's a screwy language
I'm also keeping an eye on this in case it ends up including any hints regarding updating a document in a compendium. It would be nice to be able to have my "update thumbs" script do it for adventures too
Okay, looks promising. I can see the two objects and I should be able to filter the stuff out. Gonna test this out
Just wanted to add that as a professional creative director who regularly works in web development and has had to work in CSS for over 2 decades.... yes, this is 100% true. Very screwy language.
@torpid forge Let's do a dry run with this first. Replace the adventure's UUID and the scene's name at the top. Then run it with the browser's console open to see what the macro is printing out, specifically that toCreate and toUpdate variables.
const adventure = await fromUuid("Compendium.house-divided.house-divided.Adventure.5Rmjr0A1yBkefVbg");
const sceneName = "First Floor (Ruined)";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
// clear all creates but scenes
for (let key in toCreate) {
if (key !== "Scene") delete toCreate[key];
}
// filter just the one scene
toCreate.Scene = toCreate.Scene.filter(doc => doc.name === sceneName)
console.log("toCreate:", toCreate);
console.log("toUpdate:", toUpdate);
return false;
});
await adventure.import();
hopefully it'll look something like this, and if you expand Scenes it's only got the one you want in it
Alright, one second
Hey man, I'm sorry, I'm an idiot
Is the UUID just the string you get when you copy it?
cu825MCImBiSaJTQ
?
right-click on that document icon to get the UUID
kk, so I just need that string you get on copying
I just noticed you had the compendium.house-divided, etc in front of it.
And wondered if I had manyually parse the compendium name in front of the UUID
With the UUID, we don't have to figure out the exact path to get it from a compendium. Can let the fromUuid function do that work for us
Is what the console returns
const adventure = await fromUuid("cu825MCImBiSaJTQ");
const sceneName = "A - Gauntlight Ruins)";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
// clear all creates but scenes
for (let key in toCreate) {
if (key !== "Scene") delete toCreate[key];
}
// filter just the one scene
toCreate.Scene = toCreate.Scene.filter(doc => doc.name === sceneName)
console.log("toCreate:", toCreate);
console.log("toUpdate:", toUpdate);
return false;
});
await adventure.import();
Wait
I missed a )
open up the adventure and right-click on this icon, then paste it in place of that ID
(right, not left)
I did?
(or if v12, left, not right)
yeah, hate that they switched it
there should be some stuff above that
Okay, toCreate.Scene is empty
Let's try this:
const adventure = await fromUuid("Compendium.house-divided.house-divided.Adventure.5Rmjr0A1yBkefVbg");
const sceneName = "First Floor (Ruined)";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
// clear all creates but scenes
for (let key in toCreate) {
if (key !== "Scene") delete toCreate[key];
}
console.log("toCreate:", toCreate);
console.log("toUpdate:", toUpdate);
return false;
});
await adventure.import();
all I did was remove the scene filtering, maybe it won't be necessary for you
Oh shit
How am I just now realizing that right and left click grabbed different links?
It's listing two scenes there. Are you okay if it creates 2 scenes?
One's the ID the other's the UUID (which includes the ID and other info)
Yeah
you could expand that and peek at them, but might be fine
Okay, just to be safe, have you taken a backup of this world? I've done my best to not be descructive, but it never hurts
One is literally a single room in teh default state
Yeah
I've got a backup
I really appreciate you.
All I'm doing is removing the return false; line
const adventure = await fromUuid("Compendium.house-divided.house-divided.Adventure.5Rmjr0A1yBkefVbg");
const sceneName = "First Floor (Ruined)";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
// clear all creates but scenes
for (let key in toCreate) {
if (key !== "Scene") delete toCreate[key];
}
console.log("toCreate:", toCreate);
console.log("toUpdate:", toUpdate);
});
await adventure.import();
Negative
Need a young priest and an old priest.
Quite maddening. I understand the convenience and security of a packaged adventure, but this is a bit silly.
Should be able to import ala carte from a drop down
What do you see when you run this? I'm wondering if there's a folder that's also missing, causing it not to show up
const adventure = await fromUuid("Compendium.house-divided.house-divided.Adventure.5Rmjr0A1yBkefVbg");
const sceneName = "First Floor (Ruined)";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
console.log("toCreate:", toCreate);
console.log("toUpdate:", toUpdate);
return false;
});
await adventure.import();
(but I would have thought it'd show the scene even if the folder's missing, just outside any folders)
No, IIRC due to the way rendering is done a document with a folder set but no folder present won't render in the sidebar
Still has the one I ddin't delete.
๐ How did it go from wanting to create 2 scenes to creating 13?
Just need the gauntlight ruins bit
But that is the 13
I think it might be callign two objects because the scene has a foreground and background layer?
But really I'm just fingerpainting in my own poo over here.
Which I'm sure is immediately apparent to anyone with any actual acumen at this.
Odd, the test I ran with House Divided worked. Could try to run this version, filtering on the name:
const adventure = await fromUuid("Compendium.house-divided.house-divided.Adventure.5Rmjr0A1yBkefVbg");
const sceneName = "A - Gauntlight Ruins";
Hooks.once("preImportAdventure", (adventure, importOptions, toCreate, toUpdate) => {
// clear all updates
for (let key in toUpdate) {
delete toUpdate[key];
}
// clear all creates but scenes
for (let key in toCreate) {
if (key !== "Scene") delete toCreate[key];
}
// filter just the one scene
toCreate.Scene = toCreate.Scene.filter(doc => doc.name === sceneName)
});
await adventure.import();
Do I still just replace the top text?
Wrong uuid ๐
thank goodness
I was like, "if this doesn't work, then I'm out of ideas"