#Compendium Woes

1 messages ยท Page 1 of 1 (latest)

long plover
#

@unborn lynx

unborn lynx
#

new - Compendium.rates-compendiums.classes.Item.49epOthYTBiIhyKh
old - Compendium.world.classes-2014.Item.pvEzGSv71zBhaolc

long plover
#

Oof.

#

Not the same id. Guessing that isn't an option when exporting.

#

Actually, yes it is. So you must have forgot to check that.

unborn lynx
#

the ID box when importing?

long plover
#

and when exporting

unborn lynx
#

doing it again from scratch for classes only

#

for some reason it is only importing 1 class out of all the ones I had created now..

long plover
#

Clear out the items sidebar

#

probably tossing things into various weird places due to importing multiple times

#

Clean slate please.
(and if we could speed this up a bit that would be good)

unborn lynx
#

new - Compendium.rates-compendiums.classes.Item.pvEzGSv71zBhaolc
old - Compendium.world.classes-2014.Item.pvEzGSv71zBhaolc

long plover
#

There we go.

unborn lynx
#

I could've sworn that I did it before though (looks like I didn't)

long plover
#

OK. Repeat this process for each of the compendiums.

I assume that you have the same compendiums, i.e., they map 1-to-1 world-to-module?

#

That will be the first step.

unborn lynx
#

correct, I want to send the world compendiums I created to the module in exactly the same structure

long plover
#

๐Ÿ‘

unborn lynx
#

by the way, how formatting proof is the module?

long plover
#

Formatting?

unborn lynx
#

do I need to do some kind of back up external hard drives, or cloud to make sure I don't lose it if I ever need to format?

#

the pc

long plover
#

I will suggest making a backup every now and then. I use github.

unborn lynx
#

If I ever need to format the PC, do I ever risk losing the module? or is it always within my Foundry VTT account?

long plover
#

It exists only on your PC.

unborn lynx
#

ok, so file/folder back up is a must

#

thank you very much for this Zhell

#

I have a lot more questions, but I'll focus on completing this portion and will bring the other questions at a later time ๐Ÿ™‚

long plover
#

You dont want help fixing the linking after all?

unborn lynx
#

oh, I though it was done ๐Ÿ˜…

#

then yes, I do want help with it

long plover
#

No, I said this was the first step.

unborn lynx
#

oh

#

then I'm ready to continue to the next steps

long plover
#

Great.

#

Q: Does your world contain any compendiums that are not related to this? (Ignoring system or module compendiums.)

unborn lynx
#

I cleared all the modules in order to avoid confusions.
I have the SRD, the Compendium I've created and the module I want to move the compendium I created to.

long plover
#

๐Ÿ‘

#

While I type, make a backup:

  • Shut down foundry entirely.
  • Make a copy of your module somewhere.
  • Boot foundry back up and enter the world.
#

I will also need a mapping of compendium keys.
This macro will post to chat the compendium key of the compendium that you open immediately after running it:

Hooks.once('renderCompendium', (app) => ChatMessage.create({content: app.collection.collection}))

I need to explicitly know, e.g., the key of the old vs new classes pack, old vs new features pack, etc.

unborn lynx
#

Was setting up the model exactly the same way as the compendium in the world

#

now, question, where do I place the macro lines you sent me?

long plover
#

In a macro.

unborn lynx
#

Sorry Zhell, but I'm too much of a noob with this things xD

#

I need a bit more guidance on how to make a macro

long plover
#

you just click an empty spot

#

Anyway, once you have gotten all those, copy and paste them into this new macro.
It should hopefully be obvious what are just placeholders.

const keys = {
  "old key goes here": "new pack's key goes here",
  "other old key": "other new key",
  "...": "..."
};

/* ------------------------- */

for (const key of Object.values(keys)) {
  const newPack = game.packs.get(key);
  const docs = await newPack.getDocuments();
  for (const doc of docs) {
    try {
      let data = doc.toObject();
      data = JSON.stringify(data);
      for (const [k, v] of Object.entries(keys)) {
        data = data.replaceAll(k, v);
      }
      data = JSON.parse(data);
      await doc.update(data, {diff: false, recursive: false});
    } catch(err) {
      console.warn(`Failed to update item: "${doc.uuid}"`);
    }
  }
}

ui.notifications.info("Relinking complete.");

unborn lynx
#

down here?

long plover
#

Yes that is the macro hotbar.

unborn lynx
#

sorry about the dumb questions

#

I'll get there though

#

so, right now, should I paste the first or the second macro you sent?

long plover
#

No worries. I'm off now tho, but the rest of the steps are outlined above. If there's anything else I can answer questions tomorrow

#

its late here

unborn lynx
#

same

#

go and rest

unborn lynx
#

Hey @long plover , Thursday you had to leave, and to be honest I could not really understand how to make these macros work ๐Ÿ˜ฆ

#

any chance you have the time today, or should we leave it for another time?

unborn lynx
#

I have done the mapping of the compendiums, but get this error when trying to save the second macro...

long plover
#

Sure!

#

If you could paste that mapping here that would be good

unborn lynx
#

so the mapping would be like this:
"old key goes here": "new pack's key goes here",
world.backgrounds-2014: rates-compendiums.backgrounds,
world.classes-2014: rates-compendiums.classes,
world.class-and-subclass-features-2014: rates-compendiums.classes-and-sub-classes-features,
world.feats: rates-compendiums.feats-2014,
world.races-2014: rates-compendiums.races-2014,
world.subclasses-2014: rates-compendiums.sub-classes,
world.items-2014: rates-compendiums.items-2014,
world.spell-items-2014: rates-compendiums.spell-items-2014,
world.spell-list: rates-compendiums.spell-lists,
world.spells-2014: rates-compendiums.spells,
world.trade-goods-2014: rates-compendiums.trade-goods-2014,
world.tables-2014: rates-compendiums.tables-2014,

#

@long plover when you have the chance to answer I'll try to take actions as soon as possible and give you feedback on the result ๐Ÿ™‚

long plover
# unborn lynx so the mapping would be like this: `"old key goes here": "new pack's key goes he...
const keys = {
  "world.backgrounds-2014": "rates-compendiums.backgrounds",
  "world.classes-2014": "rates-compendiums.classes",
  "world.class-and-subclass-features-2014": "rates-compendiums.classes-and-sub-classes-features",
  "world.feats": "rates-compendiums.feats-2014",
  "world.races-2014": "rates-compendiums.races-2014",
  "world.subclasses-2014": "rates-compendiums.sub-classes",
  "world.items-2014": "rates-compendiums.items-2014",
  "world.spell-items-2014": "rates-compendiums.spell-items-2014",
  "world.spell-list": "rates-compendiums.spell-lists",
  "world.spells-2014": "rates-compendiums.spells",
  "world.trade-goods-2014": "rates-compendiums.trade-goods-2014",
  "world.tables-2014": "rates-compendiums.tables-2014",
};

/* ------------------------- */

ui.notifications.info("Linking...", {permanent: true});
for (const key of Object.values(keys)) {
  const newPack = game.packs.get(key);
  const docs = await newPack.getDocuments();
  for (const doc of docs) {
    try {
      let data = doc.toObject();
      data = JSON.stringify(data);
      for (const [k, v] of Object.entries(keys)) {
        data = data.replaceAll(k, v);
      }
      data = JSON.parse(data);
      await doc.update(data, {diff: false, recursive: false});
    } catch(err) {
      console.warn(`Failed to update item: "${doc.uuid}"`);
    }
  }
}
ui.notifications.clear();
ui.notifications.info("Linking complete!", {permanent: true});
unborn lynx
#

I guess I was getting the error because of a missing ",", now it's linking

long plover
#

It is gonna take a while.

#

Now, you made a backup, right?

unborn lynx
#

yes I did

#

gave me the message Linking Complete

long plover
#

That was quick.

unborn lynx
#

yeah, I was expecting loner as well

long plover
#

OK. Check if the advancements look fine?

unborn lynx
#

Advancements are still showing from the SRD

long plover
#

Oh well. Have to do it the right way then.

unborn lynx
#

although all the other stuff is linking to the compendium module

#

that's something, I guess ๐Ÿ˜„

#

rollable tables as well as items I've placed in descriptions, have been changed to the ones in the new module

long plover
#

Ah. So just nested uuids did not get replaced. Right.

#

One second.

long plover
# unborn lynx although all the other stuff is linking to the compendium module
const keys = {
  "world.backgrounds-2014": "rates-compendiums.backgrounds",
  "world.classes-2014": "rates-compendiums.classes",
  "world.class-and-subclass-features-2014": "rates-compendiums.classes-and-sub-classes-features",
  "world.feats": "rates-compendiums.feats-2014",
  "world.races-2014": "rates-compendiums.races-2014",
  "world.subclasses-2014": "rates-compendiums.sub-classes",
  "world.items-2014": "rates-compendiums.items-2014",
  "world.spell-items-2014": "rates-compendiums.spell-items-2014",
  "world.spell-list": "rates-compendiums.spell-lists",
  "world.spells-2014": "rates-compendiums.spells",
  "world.trade-goods-2014": "rates-compendiums.trade-goods-2014",
  "world.tables-2014": "rates-compendiums.tables-2014",
};

/* ------------------------- */

ui.notifications.info("Linking...", {permanent: true});

const repl = (str) => {
  for (const [k, v] of Object.entries(keys)) str = str.replaceAll(k, v);
  return str;
};

for (const key of Object.values(keys)) {
  const newPack = game.packs.get(key);
  const docs = await newPack.getDocuments();
  for (const doc of docs) {
    const {ItemGrant=[], ItemChoice=[]} = doc.advancement?.byType ?? {};
    for (const i of ItemGrant ?? []) {
      const items = i.configuration.items.map(item => ({uuid: repl(item.uuid), optional: item.optional ?? false}));
      await doc.updateAdvancement(i.id, {configuration: {items: items}});
    }
    for (const c of ItemChoice ?? []) {
      const items = c.configuration.pool.map(item => ({uuid: repl(item.uuid)}));
      await doc.updateAdvancement(c.id, {configuration: {pool: items}});
    }
  }
}
ui.notifications.clear();
ui.notifications.info("Linking complete!", {permanent: true});
#

oh hold on

#

there

unborn lynx
#

did not see the message coming in, so still didn't do anything ๐Ÿ˜„

long plover
#

(fixed another typo)

unborn lynx
#

I get this when I try to save the macro

long plover
#

Typo. Fixed.

unborn lynx
#

this was even faster

#

nothing changed in the advancements

long plover
#

hm.

#

How old are these classes and other items?

unborn lynx
#

I've installed Foundry about 1 month ago, a bit more maybe, but not too much

#

I am working on V12 since the beginning

#

I can do the advancements manually though

#

I going to rip my eye lashes out if I had to do all the descrioption item links though ๐Ÿ˜„

long plover
#

Yeah not sure why these point to non-existing items, sorry. Both of the methods tried worked fine on my end

unborn lynx
#

I think I understand why though

#

I went the lazy way in the beginning and copied all the SRD data to my compendium and started working from my world compendium after that

#

seems that only classes and subclasses that came from the SRD, haven't moved the item links

#

all the others have

#

you helped me cut a lot of correction time already

#

thank you @long plover

long plover
#

Ah. So everything is in fact re-linked. Good!

unborn lynx
#

You're amazing, thank you very much

#

I gues deleting the world compendium will not be an issue right?

long plover
#

It should not be an issue.

#

Besides, you made a backup.

#

You can also test that everything is correct by making a new world with only your module active. If things still look right, then the old world compendiums are no longer relevant.

#

Though note that if you have an ongoing game right now, you may want to replace the items on any characters.

unborn lynx
#

no game ongoing

long plover
#

No issue then!

unborn lynx
#

I am preparing everything for my first game in Foundry ๐Ÿ™‚