#Importing just one scene of an Adventure

1 messages ยท Page 1 of 1 (latest)

fiery raven
#

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

torpid forge
#

Appreciate it.

fiery raven
#

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

torpid forge
#

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.

next hinge
#

(This thread title is unfortunate lmao)

shrewd cradle
#

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

fiery raven
#

Importing just one scene of an Adventure

shrewd cradle
#

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

fiery raven
#

Okay, looks promising. I can see the two objects and I should be able to filter the stuff out. Gonna test this out

torpid spear
fiery raven
#

@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

torpid forge
#

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

#

?

fiery raven
#

right-click on that document icon to get the UUID

torpid forge
#

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

fiery raven
#

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

torpid forge
#

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 )

fiery raven
#

open up the adventure and right-click on this icon, then paste it in place of that ID

next hinge
#

(right, not left)

torpid forge
#

I did?

next hinge
#

(or if v12, left, not right)

torpid forge
#

Right clicking that gets me this

fiery raven
#

yeah, hate that they switched it

torpid forge
#

Oh wait

#

Nevermind

#

Sorry. I did mention I'm an idiot, yeah?

fiery raven
#

there should be some stuff above that

torpid forge
fiery raven
#

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();
torpid forge
#

I'm just a monkey.

#

kk

fiery raven
#

all I did was remove the scene filtering, maybe it won't be necessary for you

torpid forge
#

Oh shit

#

How am I just now realizing that right and left click grabbed different links?

fiery raven
#

It's listing two scenes there. Are you okay if it creates 2 scenes?

shrewd cradle
#

One's the ID the other's the UUID (which includes the ID and other info)

torpid forge
#

Yeah

fiery raven
#

you could expand that and peek at them, but might be fine

torpid forge
#

I know the two, I'm fairly certain

#

And replacing both would be fine

fiery raven
#

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

torpid forge
#

One is literally a single room in teh default state

#

Yeah

#

I've got a backup

#

I really appreciate you.

fiery raven
#

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();
torpid forge
#

This shit is so alien to me.

fiery raven
#

๐Ÿคž

#

Go check if the scene you want is there in the sidebar

torpid forge
#

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

fiery raven
#

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)

torpid forge
#

The folder is def there

#

IT had two scenes in it

shrewd cradle
torpid forge
#

Still has the one I ddin't delete.

fiery raven
#

๐Ÿ˜– How did it go from wanting to create 2 scenes to creating 13?

torpid forge
#

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.

fiery raven
#

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();
torpid forge
#

Do I still just replace the top text?

fiery raven
#

in this case, just the first line

#

I put the sceneName in there

torpid forge
#

Wait

next hinge
#

Wrong uuid ๐Ÿ™‚

torpid forge
#

wrong click

#

damnit

#

YOU MAGNIFICENT BASTARD

#

A MILLION POINTS KAELAD

fiery raven
#

thank goodness

torpid forge
#

Thank you so much.

#

That was a lot of work teaching me to ride a bike.

fiery raven
#

I was like, "if this doesn't work, then I'm out of ideas"

torpid forge
#

Turns out it was calling two scenes, becasue the Paizo stuff is packaged with original and 'enchanced' versions of the maps.

#

So it grabbed both

#

Everyhting else is 5x5, nothing is corrupted. All my scnee and actor data is fine.

#

Thank you again.