2.2.0 release #38
53
macros/requestDialog.js
Normal file
53
macros/requestDialog.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
async function main () {
|
||||||
|
let tokens = Array.from(game.user.targets)
|
||||||
|
if (tokens.length < 1) {
|
||||||
|
tokens = canvas.tokens.controlled
|
||||||
|
}
|
||||||
|
if (tokens.length < 1) {
|
||||||
|
ui.notifications.error('Please target or select some tokens')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const menuData = {
|
||||||
|
inputs: [
|
||||||
|
{ type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: 'Trait to roll',
|
||||||
|
options: []
|
||||||
|
},
|
||||||
|
{ type: 'number', label: 'Roll Modifier', options: 0 },
|
||||||
|
{ type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' }
|
||||||
|
],
|
||||||
|
buttons: [
|
||||||
|
{ label: 'Request roll', value: 'ok', default: true },
|
||||||
|
{ label: 'Cancel', value: 'cancel' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
const menuConfig = {
|
||||||
|
title: 'Request roll...'
|
||||||
|
}
|
||||||
|
for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) {
|
||||||
|
menuData.inputs[1].options.push(
|
||||||
|
{ html: `Attribute | ${attribute}`, value: `a|${attribute.toLowerCase()}` }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const skillSet = new Set()
|
||||||
|
for (const token of tokens) {
|
||||||
|
const skills = token.actor.items.filter(i => i.type === 'skill' &&
|
||||||
|
!['Untrained', 'Unskilled Attempt'].includes(i.name))
|
||||||
|
for (const skill of skills) {
|
||||||
|
skillSet.add(skill.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const skill of Array.from(skillSet).sort()) {
|
||||||
|
menuData.inputs[1].options.push(
|
||||||
|
{ html: `Skill | ${skill}`, value: `s|${skill.toLowerCase()}` })
|
||||||
|
}
|
||||||
|
menuData.inputs[1].options.push(
|
||||||
|
{ html: 'Skill | Untrained', value: 's|NOSKILL' })
|
||||||
|
const result = await warpgate.menu(menuData, menuConfig)
|
||||||
|
console.log(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
@ -11,7 +11,6 @@ export class api {
|
|||||||
static globals () {
|
static globals () {
|
||||||
const moduleName = 'swade-mb-helpers'
|
const moduleName = 'swade-mb-helpers'
|
||||||
game.modules.get(moduleName).api = {
|
game.modules.get(moduleName).api = {
|
||||||
DEBUG: true,
|
|
||||||
powerEffects,
|
powerEffects,
|
||||||
requestRollFromTokens
|
requestRollFromTokens
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user