foundryvtt-macros/Manual Roll Initiative.json
2024-12-27 09:08:55 -06:00

25 lines
1.6 KiB
JSON

{
"name": "Roll Initiative",
"type": "script",
"scope": "global",
"author": "KR32117fX0pxHkC5",
"img": "icons/svg/dice-target.svg",
"command": "let playerCombatants = [];\nlet combatants = game.combat.combatants\nfor (const combatant of combatants) {\n playerCombatants.push(combatant)\n}\n\nlet form = '<form><div class=\"form-group\" style=\"flex-direction:column;align-items:start\">';\nfor (const combatant of playerCombatants) {\n form += '<label>' + combatant.name + '</label>'\n form += '<input type=\"text\" name=\"' + combatant.id + '\"></label>';\n}\nform += '</div></form>'\n\nasync function setInitiativesAndStartCombat(html) {\n\n for (const combatant of playerCombatants) {\n let initiative = html.find('input[name=\"' + combatant.id + '\"]')[0].value\n await game.combat.setInitiative(combatant.id, initiative).then(\n\n );\n }\n await game.combat.rollNPC();\n await game.combat.startCombat();\n}\n\n\nnew Dialog({\n title: 'Manual Initiative',\n content: form,\n buttons: {\n yes: {\n icon: \"<i class='fas fa-check'></i>\",\n label: \"Start Combat\",\n callback: (html) => setInitiativesAndStartCombat(html),\n }\n },\n default: 'yes'\n}).render(true);",
"folder": null,
"flags": {
"exportSource": {
"world": "the-well-wishers",
"system": "dnd5e",
"coreVersion": "11.315",
"systemVersion": "3.1.1"
}
},
"_stats": {
"systemId": "dnd5e",
"systemVersion": "3.1.1",
"coreVersion": "11.315",
"createdTime": 1712067301107,
"modifiedTime": 1712067772822,
"lastModifiedBy": "KR32117fX0pxHkC5"
}
}