Created
February 23, 2023 09:35
-
-
Save dealloc/f0e62ead624c56dcecb129ebca940cc2 to your computer and use it in GitHub Desktop.
Foundry Skill Check Macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const skills = [ | |
{ label: 'Perception', value: 'perception' }, | |
{ label: 'Acrobatics', value: 'acrobatics' }, | |
{ label: 'Deception', value: 'deception' }, | |
{ label: 'Intimidation', value: 'intimidation' }, | |
{ label: 'Nature', value: 'nature' }, | |
{ label: 'Performance', value: 'performance' }, | |
{ label: 'Society', value: 'society' }, | |
{ label: 'Survival', value: 'survival' }, | |
{ label: 'Arcana', value: 'arcana' }, | |
{ label: 'Crafting', value: 'crafting' }, | |
{ label: 'Diplomacy', value: 'diplomacy' }, | |
{ label: 'Medicine', value: 'medicine' }, | |
{ label: 'Occultism', value: 'occultism' }, | |
{ label: 'Religion', value: 'religion' }, | |
{ label: 'Stealth', value: 'stealth' }, | |
{ label: 'Thievery', value: 'thievery' } | |
]; | |
const makeButton = (skill) => ({ | |
icon: '', | |
label: skill.label, | |
callback: () => { | |
new Dialog({ | |
title: 'DC', | |
content: `<form> | |
<input name="DC" type="number" min="1" max="40" value="15" /> | |
</form>`, | |
buttons: { | |
roll: { | |
label: 'Roll', | |
callback: (html) => { | |
const dc = Number(html.find('[name=DC]').val()); | |
ChatMessage.create({ | |
user: game.user_id, | |
//speaker: ChatMessage.getSpeaker({ token: actor }), | |
content: `@Check[type:${skill.value}|dc:${dc}]{${skill.label} Skill Check}` | |
}); | |
} | |
} | |
} | |
}).render(true); | |
} | |
}); | |
new Dialog({ | |
title: 'Skill check', | |
content: '<p>What skill do you want to check?</p>', | |
buttons: skills.reduce((acc, val) => ({...acc, [val.value]: makeButton(val) }), {}), | |
}).render(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment