Created
June 27, 2024 12:52
-
-
Save OranShuster/41273d9e0b47125036a78ec32a298ff7 to your computer and use it in GitHub Desktop.
Foundry VTT macro to calculate pythagorean distance
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
new Dialog({ | |
title:'Example Dialog', | |
content:` | |
<form> | |
<div class="form-group"> | |
<label>Distance</label> | |
<input type='text' name='distance'></input> | |
<label>Height</label> | |
<input type='text' name='height'></input> | |
</div> | |
</form>`, | |
buttons:{ | |
yes: { | |
icon: "<i class='fas fa-check'></i>", | |
label: "Calculate" | |
}}, | |
default:'yes', | |
close: html => { | |
let d = html.find('input[name=\'distance\']'); | |
let h = html.find('input[name=\'height\']'); | |
if (d.val()!== '' && h.val()!== '') { | |
let calc = Math.sqrt(Math.pow(parseInt(d.val()),2) + Math.pow(parseInt(h.val()),2)); | |
let chatData = { | |
content: calc | |
}; | |
ChatMessage.create(chatData, {}); | |
} | |
} | |
}).render(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment