28 lines
2.7 KiB
JSON
28 lines
2.7 KiB
JSON
{
|
|
"name": "Request Roll",
|
|
"type": "script",
|
|
"scope": "global",
|
|
"author": "R9ZgY0IvWl8ovIuT",
|
|
"img": "icons/sundries/gaming/dice-runed-tan.webp",
|
|
"command": "const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },\n {\n type: 'select',\n label: 'Trait to roll',\n options: []\n },\n { type: 'number', label: 'Roll Modifier', options: 0 },\n { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' }\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: 'Request roll...'\n }\n for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) {\n menuData.inputs[1].options.push(\n { html: `Attribute | ${attribute}`, value: `a|${attribute}` }\n )\n }\n const skillSet = new Set()\n for (const token of tokens) {\n const skills = token.actor.items.filter(i => i.type === 'skill' &&\n !['Untrained', 'Unskilled Attempt'].includes(i.name))\n for (const skill of skills) {\n skillSet.add(skill.name)\n }\n }\n for (const skill of Array.from(skillSet).sort()) {\n menuData.inputs[1].options.push(\n { html: `Skill | ${skill}`, value: `s|${skill}` })\n }\n menuData.inputs[1].options.push(\n { html: 'Skill | Untrained', value: 's|NOSKILL' })\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const rollMod = result.inputs[2]\n const rollModDesc = result.inputs[3]\n const rollParts = result.inputs[1].split('|')\n const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill')\n const rollDesc = rollParts[1]\n const options = {}\n if (rollMod !== 0) {\n options.mods = [{ label: rollModDesc, value: rollMod }]\n }\n\n requestRollFromTokens(tokens, rollType, rollDesc, options)\n}\n\nmain()",
|
|
"folder": null,
|
|
"ownership": {
|
|
"default": 0,
|
|
"R9ZgY0IvWl8ovIuT": 3
|
|
},
|
|
"flags": {
|
|
"core": {}
|
|
},
|
|
"_stats": {
|
|
"systemId": "swade",
|
|
"systemVersion": "3.2.5",
|
|
"coreVersion": "11.315",
|
|
"createdTime": 1700430548162,
|
|
"modifiedTime": 1702959790712,
|
|
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
|
},
|
|
"_id": "G9ksuYJo1512PTo9",
|
|
"sort": 400000,
|
|
"_key": "!macros!G9ksuYJo1512PTo9"
|
|
}
|