This isn't inside a function that's only called sometimes right?
This isn't inside a function that's only called sometimes right?
console.warn as the hook function.called.$(".my-button").on("click", () => doSomething())flattenTilePrompt() when clicked). Hooks.on("hookName", callback), which will call callback whenever the hookName hook is thrown out by part of the code. The hook will pass arguments, which are generally used to go "hey, I'm doing this, and this is the data I'm doing it with".buttons, which is an array of each of the scene tools.
console.warncall$(".my-button").on("click", () => doSomething())flattenTilePrompt()Hooks.on("hookName", callback)callbackbuttons static call(hook, ...args) {
if ( CONFIG.debug.hooks ) {
console.log(`DEBUG | Calling ${hook} hook with args:`);
console.log(args);
}
if ( !this._hooks.hasOwnProperty(hook) ) return;
const fns = new Array(...this._hooks[hook]);
for ( let fn of fns ) {
let callAdditional = this._call(hook, fn, args);
if ( callAdditional === false ) return false;
}
return true;
}Hooks.on("getSceneControlButtons", addFlattenerButton); //add the button for this to the menu
function addFlattenerButton(buttons) {
let tilesButton = buttons.find(b => b.name == "tiles")
if (tilesButton) {
tilesButton.tools.push({
name: "request-roll",
title: game.i18n.localize('TILE-FLATTENER.Button'),
icon: "fas fa-layer-group",
visible: game.user.isGM,
onClick: () => flattenTilePrompt(),
button: true
});
}
};