Forked from antonioeduardofernandes/gist:3d1ab814cc93570472ac67517a4a09e3
Created
May 26, 2022 12:29
-
-
Save p4535992/0ced73ebeca8b54ee28d344818d622da to your computer and use it in GitHub Desktop.
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
async function determineWeather(currentWeather) { | |
//roll the dice and get the result | |
let diceRoll = await new Roll("1d20").evaluate() | |
let diceResult = await diceRoll.result | |
// selects the table to roll based on current weather input from Dialog | |
let tableToRoll | |
switch (currentWeather) { | |
case "no": | |
tableToRoll = "noWind" | |
break | |
case "low": | |
tableToRoll = "lowWind" | |
break | |
case "high": | |
tableToRoll = "highWind" | |
break | |
} | |
//roll on the correct table | |
const weatherResult = await game.tables.getName(tableToRoll).getResultsForRoll(diceResult)[0].data.text | |
//content | |
const content = ` | |
<p style="font-size:22px;">Weather Result:<\p> <span>${weatherResult}</span> | |
` | |
//display the content just for the loremaster (or anyone who triggered this macro) | |
ChatMessage.create({ content, whisper: [game.user] }) | |
} | |
//Dialog | |
let weatherPrompt = await Dialog.prompt({ | |
content: ` | |
<h1>Current Weather</h1> | |
<select id="currentWeather"> | |
<option value="no">No Winds</option> | |
<option value="low">Low Winds</option> | |
<option value="high">High Winds</option> | |
</select> | |
`, | |
callback: html => { | |
let currentWeather = html.find('[id="currentWeather"]:checked').value | |
determineWeather(currentWeather) | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment