mirror of
https://github.com/migatu/vtt_work.git
synced 2026-07-14 21:38:39 +00:00
dd
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{"_id": "4be25d217b8dd9de", "name": "Add Gear to Selected Voidship", "type": "script", "img": "icons/svg/plus.svg", "command": "(async ()=>{const a=canvas.tokens.controlled[0]?.actor; if(!a) return ui.notifications.warn('Select a voidship token.'); const pack=game.packs.get('wg-voidships-builder.wg-voidship-items'); if(!pack) return ui.notifications.error('Items pack not found.'); const index=await pack.getIndex(); const names=index.map(e=>e.name).sort(); const opts=names.map(n=>`<option>${n}</option>`).join(''); const content=`<p>Choose items to add (Ctrl/Cmd+Click):</p><select id=it multiple size=12 style='width:100%'>${opts}</select>`; new Dialog({title:'Add Gear', content, buttons:{ok:{label:'Add',callback:async html=>{const sel=[...html[0].querySelector('#it').selectedOptions].map(o=>o.value); const docs=await pack.getDocuments({name:{$in:sel}}); const data=docs.map(d=>d.toObject()); await a.createEmbeddedDocuments('Item', data); ui.notifications.info(`Added ${sel.length} item(s) to ${a.name}.`);}}}}).render(true);})();", "scope": "global", "author": null, "ownership": {"default": 2}}
|
||||
{"_id": "41ade68c839678fa", "name": "Remove All Gear (Selected)", "type": "script", "img": "icons/svg/trash.svg", "command": "(async()=>{const a=canvas.tokens.controlled[0]?.actor; if(!a) return ui.notifications.warn('Select a voidship token.'); const ids=a.items.filter(i=>['gear','weapon'].includes(i.type)).map(i=>i.id); if(!ids.length) return ui.notifications.info('No gear/weapon items to remove.'); await a.deleteEmbeddedDocuments('Item', ids); ui.notifications.info(`Removed ${ids.length} items from ${a.name}.`);})();", "scope": "global", "author": null, "ownership": {"default": 2}}
|
||||
{"_id": "5079989f359a3c3d", "name": "Toggle Geller (Primary/Reserve)", "type": "script", "img": "icons/svg/aura.svg", "command": "(async()=>{const a=canvas.tokens.controlled[0]?.actor; if(!a) return ui.notifications.warn('Select a voidship token.'); const g=a.getFlag('wg-voidships','geller')||{primaryActive:false,reserveActive:false}; const content=`<p>Primary: <input type=checkbox id=p ${g.primaryActive?'checked':''}></p><p>Reserve: <input type=checkbox id=r ${g.reserveActive?'checked':''}></p>`; new Dialog({title:'Geller Fields',content,buttons:{ok:{label:'Set',callback:async html=>{const p=html[0].querySelector('#p').checked; const r=html[0].querySelector('#r').checked; await a.setFlag('wg-voidships','geller',{primaryActive:p,reserveActive:r}); ChatMessage.create({content:`${a.name}: Geller Primary ${p?'ON':'OFF'} / Reserve ${r?'ON':'OFF'}`});}}}}).render(true);})();", "scope": "global", "author": null, "ownership": {"default": 2}}
|
||||
{"_id": "6a4bc2349dda4733", "name": "Organize Builder Compendia Folders", "type": "script", "img": "icons/svg/folder.svg", "command": "(async ()=>{\n const moduleId = \"wg-voidships-builder\";\n const packs = {\n items: game.packs.get(`${moduleId}.wg-voidship-items`),\n hulls: game.packs.get(`${moduleId}.wg-voidship-hulls`)\n };\n async function ensureFolder(pack, name) {\n await pack.getIndex();\n const typeName = pack.documentName; // \"Item\" or \"Actor\"\n const existing = pack.folders.find(f => f.name === name);\n if (existing) return existing;\n return Folder.create({ name, type: typeName, sorting: \"a\" }, { pack: pack.collection });\n }\n // Items\n if (packs.items) {\n const fWeapons = await ensureFolder(packs.items, \"Weapons\");\n const fEssential = await ensureFolder(packs.items, \"Essential Components\");\n const fSupplemental = await ensureFolder(packs.items, \"Supplemental Components\");\n const fOrdnance = await ensureFolder(packs.items, \"Ordnance\");\n const docs = await packs.items.getDocuments();\n for (const d of docs) {\n const kw = String(d.system?.keywords ?? \"\").toUpperCase();\n let folder = fSupplemental;\n if (d.type === \"weapon\") folder = fWeapons;\n else if (kw.includes(\"ESSENTIAL\")) folder = fEssential;\n else if (kw.includes(\"ORDNANCE\")) folder = fOrdnance;\n if (!d.folder || d.folder.id !== folder.id) {\n await d.update({ folder: folder.id }, { pack: packs.items.collection });\n }\n }\n }\n // Hulls\n if (packs.hulls) {\n const fHulls = await ensureFolder(packs.hulls, \"Hulls\");\n const docs = await packs.hulls.getDocuments();\n for (const d of docs) {\n if (!d.folder || d.folder.id !== fHulls.id) {\n await d.update({ folder: fHulls.id }, { pack: packs.hulls.collection });\n }\n }\n }\n ui.notifications.info(\"Voidships Builder: Compendium folders organized.\");\n})();", "scope": "global", "author": null, "ownership": {"default": 2}}
|
||||
Reference in New Issue
Block a user