add handlebars value comparison helper

This commit is contained in:
Chris Schmalz
2023-08-31 18:03:39 -07:00
parent 94eb7954f0
commit 9ca5adbb1d
+20 -1
View File
@@ -65,12 +65,31 @@ Hooks.once('init', async function () {
return outStr;
});
Handlebars.registerHelper('toLowerCase', function (str) {
return str.toLowerCase();
});
Handlebars.registerHelper('compare', function (varType, varOne, comparator, varTwo) {
if (varType === 'str') {
if (eval('"' + varOne + '"' + comparator + '"' + varTwo+ '"')) {
return true
} else {
return false
}
} else if (varType === 'int') {
if (eval(varOne + comparator + varTwo)) {
return true
} else {
return false
}
}
});
});
Hooks.once("ready", async function () {
// Wait to register hotbar drop hook on ready so that modules could register earlier if they want to
Hooks.on("hotbarDrop", (bar, data, slot) => createMothershipMacro(data, slot));