Created
February 22, 2021 01:19
-
-
Save jenthura/e635060caed06e3141c8b55f040039e6 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
let temp = [`Normal for the season`,`${(Math.ceil(Math.random()*4))*10} degrees Fahrenheit colder than normal`,`${(Math.ceil(Math.random()*4))*10} degrees Fahrenheit hotter than normal`]; | |
let wind = [`None`,`Light`,`Strong`]; | |
let precip = [`None`, `Light rain or light snowfall`,` Heavy rain or heavy snowfall`]; | |
function roll(){return Math.ceil(Math.random()*20)} | |
function rollTable(name,arr,first,second,third,fourth) { | |
let tempRoll = roll() | |
let message = `${name}: `; | |
if (tempRoll <= first) { | |
message += (arr[0]) += '.\n' | |
} | |
if (tempRoll >= second && tempRoll <= third) { | |
message += (arr[1]) += '.\n' | |
} | |
if (tempRoll >= fourth) { | |
message += (arr[2]) += '.\n' | |
} | |
return message | |
} | |
function weather() { | |
let report = 'Weather report: \n' | |
report += rollTable('Temp',temp,14,15,17,18) | |
report += rollTable('Wind',wind,12,13,17,18) | |
report += rollTable('Precipitation',precip,12,13,17,18) | |
return report | |
} | |
let message = weather() | |
let d = new Dialog({ //dialog object creates the window with all the buttons | |
title: "A Dream occurs", | |
content: `<h2>Are you sure you want to create weather?<h2>`, | |
buttons: { | |
one: { | |
label: "Yes", | |
callback: () => {ChatMessage.create({ | |
user : game.user._id, | |
content: message | |
}); | |
} | |
}, | |
two: { | |
label: "No", | |
callback: () => {console.log(`Done`)} | |
}, | |
}, | |
render: html => console.log("Register interactivity in the rendered dialog"), | |
close: html => console.log("This always is logged no matter which option is chosen") | |
}); | |
d.render(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment