mb-assets/packsrc/asset-macros/Tree_Style_Select_qD7v8yTOa2TNi2DL.json
2025-06-22 21:36:21 -05:00

29 lines
1.9 KiB
JSON

{
"folder": "1e5EaquD2GTpHlOW",
"name": "Tree Style Select",
"type": "script",
"_id": "qD7v8yTOa2TNi2DL",
"author": "sVoCvBU1knmXzoYe",
"img": "icons/environment/wilderness/tree-oak.webp",
"scope": "global",
"command": "let choices = {\n 'Green': 'Green',\n 'Multicolor1': 'Multi-color',\n 'Red': 'Red',\n 'Yellow': 'Yellow',\n 'Multicolor2': 'Fey1',\n 'Multicolor3': 'Fey2'\n};\nlet content = '<select name=\"style\" autofocus>';\nfor (let choice in choices) {\n content += `<option value=\"${choice}\">${choices[choice]}</option>`;\n}\ncontent += '</select>';\nlet style;\ntry {\n style = await foundry.applications.api.DialogV2.prompt({\n window: { title: \"Choose Tree Style\" },\n content,\n ok: {\n label: 'Set Tree Style',\n callback: (event, button, dialog) => button.form.elements.style.value\n }\n });\n} catch {\n console.log(\"no choice made\");\n return;\n}\nif (!style) {\n console.log(\"no choice made\");\n return;\n}\n\nlet updates = [];\nlet trees = canvas.scene.tiles.filter(t => Tagger.hasTags(t, 'TreeCanopy')).forEach(t => {\n let styleimg\n if (style === 'Green' && t.flags['multiface-tiles']?.originalImage) {\n styleimg = t.flags['multiface-tiles']?.originalImage\n } else {\n styleimg = t.flags['multiface-tiles']?.altImages?.find(i => i.indexOf(style) > -1)\n }\n if (styleimg) {\n updates.push({'_id': t.id, 'texture.src': styleimg})\n }\n});\ncanvas.scene.updateEmbeddedDocuments('Tile', updates)",
"sort": 0,
"ownership": {
"default": 0,
"sVoCvBU1knmXzoYe": 3
},
"flags": {},
"_stats": {
"compendiumSource": null,
"duplicateSource": null,
"exportSource": null,
"coreVersion": "13.345",
"systemId": "swade",
"systemVersion": "5.0.3",
"createdTime": 1750627757667,
"modifiedTime": 1750630748699,
"lastModifiedBy": "sVoCvBU1knmXzoYe"
},
"_key": "!macros!qD7v8yTOa2TNi2DL"
}