mirror of
https://github.com/migatu/vtt_work.git
synced 2026-07-18 15:52:11 +00:00
Import wrath-and-glory-gk-0.2.0.zip do wg-greyknights (2025-08-21T20:12:55Z)
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
// GK – Auto Loadout on Archetype Assignment (world esmodule friendly)
|
||||
(() => {
|
||||
if (window._gkAutoLoadoutHook) { return; }
|
||||
window._gkAutoLoadoutHook = Hooks.on("createItem", async (item, opts, userId) => {
|
||||
try {
|
||||
if (item?.type !== "archetype") return;
|
||||
if (item?.name !== "Grey Knight (Archetype)") return;
|
||||
const actor = item.parent;
|
||||
if (!actor || game.userId !== userId) return;
|
||||
const macro = game.macros.getName("GK – Loadout Manager") || game.macros.getName("GK-Loadout-Manager");
|
||||
if (macro) await macro.execute();
|
||||
else ui.notifications.warn("Brak makra 'GK – Loadout Manager'. Dodaj je do świata (macros/).");
|
||||
} catch (e) { console.error("GK Auto-Loadout error", e); }
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,29 @@
|
||||
// GK Importer: drop a folder path that contains JSON items exported from Foundry and import them.
|
||||
(async () => {
|
||||
const dir = await new Promise(resolve => {
|
||||
new Dialog({
|
||||
title: "GK Importer — pick folder URL or paste path",
|
||||
content: `<p>Paste a data path (e.g. /worlds/your-world/foundry/items)</p><input type="text" name="path" style="width:100%"/>`,
|
||||
buttons: {
|
||||
ok: { label: "Import", callback: html => resolve(html.find('input[name="path"]').val()) },
|
||||
cancel: { label: "Cancel", callback: () => resolve(null) }
|
||||
},
|
||||
default: "ok"
|
||||
}).render(true);
|
||||
});
|
||||
if (!dir) return;
|
||||
const response = await FilePicker.browse("data", dir);
|
||||
const files = response.files.filter(f => f.endsWith(".json"));
|
||||
for (const f of files) {
|
||||
try {
|
||||
const json = await (await fetch(f)).json();
|
||||
if (json.type && (json.name || json.label)) {
|
||||
if (!json.name && json.label) json.name = json.label;
|
||||
await Item.create(json);
|
||||
}
|
||||
} catch (err) {
|
||||
ui.notifications.error(`Import failed for ${f}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
ui.notifications.info("GK Import complete.");
|
||||
})();
|
||||
Reference in New Issue
Block a user