More WIP on 0.8.x migration

This commit is contained in:
Johannes Loher 2021-06-30 04:32:10 +02:00
parent 6b39284164
commit ba493f4f18
13 changed files with 55 additions and 38 deletions

View file

@ -15,15 +15,13 @@ import { getActiveActor } from "./helpers";
*/
export async function createRollCheckMacro(check: Check, slot: string): Promise<void> {
const macro = await getOrCreateRollCheckMacro(check);
game.user?.assignHotbarMacro(macro, slot);
game.user?.assignHotbarMacro(macro ?? null, slot);
}
async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | null> {
async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefined> {
const command = `game.ds4.macros.rollCheck("${check}");`;
const existingMacro = game.macros?.entities.find(
(m) => m.name === DS4.i18n.checks[check] && m.data.command === command,
);
const existingMacro = game.macros?.find((m) => m.name === DS4.i18n.checks[check] && m.data.command === command);
if (existingMacro) {
return existingMacro;
}
@ -36,7 +34,7 @@ async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | null> {
img: DS4.icons.checks[check],
flags: { "ds4.checkMacro": true },
},
{ displaySheet: false },
{ renderSheet: false },
);
}