diff --git a/wg-greyknights/macro/macro-gk-auto-loadout-on-archetype.js b/wg-greyknights/macro/macro-gk-auto-loadout-on-archetype.js deleted file mode 100644 index d75bf8c..0000000 --- a/wg-greyknights/macro/macro-gk-auto-loadout-on-archetype.js +++ /dev/null @@ -1,20 +0,0 @@ -// GK – Auto Loadout on Archetype Assignment -// Rejestruje Hook createItem: jeśli do aktora dodano 'Grey Knight (Archetype)', uruchomi 'GK – Loadout Manager'. -(() => { - if (window._gkAutoLoadoutHook) { ui.notifications.info("GK Auto-Loadout: już aktywne."); 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 m = game.macros.getName("GK – Loadout Manager") || game.macros.getName("GK-Loadout-Manager") || null; - if (m) { - await m.execute(); - } else { - ui.notifications.warn("Brak makra 'GK – Loadout Manager'. Utwórz je i uruchom ponownie."); - } - } catch (e) { console.error("GK Auto-Loadout error", e); } - }); - ui.notifications.info("GK Auto-Loadout: hook zarejestrowany (createItem)."); -})(); \ No newline at end of file diff --git a/wg-greyknights/macros/macro-gk-auto-loadout-on-archetype.js b/wg-greyknights/macros/macro-gk-auto-loadout-on-archetype.js new file mode 100644 index 0000000..4e3eff4 --- /dev/null +++ b/wg-greyknights/macros/macro-gk-auto-loadout-on-archetype.js @@ -0,0 +1,15 @@ +// 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); } + }); +})(); \ No newline at end of file diff --git a/wg-greyknights/macro/macro-gk-glow-toggle.js b/wg-greyknights/macros/macro-gk-glow-toggle.js similarity index 100% rename from wg-greyknights/macro/macro-gk-glow-toggle.js rename to wg-greyknights/macros/macro-gk-glow-toggle.js diff --git a/wg-greyknights/macros/macro-gk-import-world-items-FIXED.js b/wg-greyknights/macros/macro-gk-import-world-items-FIXED.js new file mode 100644 index 0000000..ffba9df --- /dev/null +++ b/wg-greyknights/macros/macro-gk-import-world-items-FIXED.js @@ -0,0 +1,80 @@ +// GK – Import World Items (from JSONs into Items Directory) — FIXED path handling +(async () => { + const FILES = [ + "fvtt-Item-archetype-grey-knight_v5.json", + "fvtt-Item-ability-aegis-of-titan_v5.json", + "fvtt-Item-nemesis-force-halberd_v4.json", + "fvtt-Item-gk-armour-integrated-storm-bolter_v2.json", + "fvtt-Item-aegis-power-armour_v2.json", + "fvtt-Item-terminator-aegis-gk_v4.json" + ]; + + const worldId = game.world?.id || game.world?.name || game.data?.world?.id || game.data?.world?.name; + const defaultDir = `worlds/${worldId}/foundry`; + + const pick = await new Promise(resolve => { + const content = ` +
Folder z JSON-ami (domyślnie: ${defaultDir})