Rename a few things
This commit is contained in:
parent
67d0253f66
commit
32fac517ad
7 changed files with 16 additions and 16 deletions
|
@ -4,7 +4,7 @@ import { DS4CreatureActorSheet } from "./actor/sheets/creature-sheet";
|
|||
import { DS4 } from "./config";
|
||||
import registerHandlebarsHelpers from "./handlebars/handlebars-helpers";
|
||||
import registerHandlebarsPartials from "./handlebars/handlebars-partials";
|
||||
import registerHooks from "./hooks/hooks";
|
||||
import registerForHooks from "./hooks/hooks";
|
||||
import { DS4Item } from "./item/item";
|
||||
import { DS4ItemSheet } from "./item/item-sheet";
|
||||
import { macros } from "./macros/macros";
|
||||
|
@ -53,7 +53,7 @@ Hooks.once("init", async () => {
|
|||
await registerHandlebarsPartials();
|
||||
registerHandlebarsHelpers();
|
||||
|
||||
registerHooks();
|
||||
registerForHooks();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import registerHotbarHook from "./hotbar-drop";
|
||||
import registerForHotbarDropHook from "./hotbar-drop";
|
||||
|
||||
export default function registerHooks(): void {
|
||||
registerHotbarHook();
|
||||
export default function registerForHooks(): void {
|
||||
registerForHotbarDropHook();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { DS4Item } from "../item/item";
|
||||
import { DS4ItemData } from "../item/item-data";
|
||||
import { createItemMacro } from "../macros/item-macro";
|
||||
import { createRollItemMacro } from "../macros/roll-item-macro";
|
||||
import notifications from "../ui/notifications";
|
||||
|
||||
export default function registerHotbarHook(): void {
|
||||
export default function registerForHotbarDropHook(): void {
|
||||
Hooks.on("hotbarDrop", async (hotbar: Hotbar, data: { type: string } & Record<string, unknown>, slot: string) => {
|
||||
switch (data.type) {
|
||||
case "Item": {
|
||||
|
@ -21,7 +21,7 @@ export default function registerHotbarHook(): void {
|
|||
}),
|
||||
);
|
||||
}
|
||||
await createItemMacro(itemData, slot);
|
||||
await createRollItemMacro(itemData, slot);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { rollItemMacro } from "./item-macro";
|
||||
import { rollItem } from "./roll-item-macro";
|
||||
|
||||
export const macros = {
|
||||
rollItemMacro,
|
||||
rollItem: rollItem,
|
||||
};
|
||||
|
|
|
@ -9,8 +9,8 @@ import notifications from "../ui/notifications";
|
|||
* @param itemData - The item data
|
||||
* @param slot - The hotbar slot to use
|
||||
*/
|
||||
export async function createItemMacro(itemData: DS4ItemData, slot: string): Promise<void> {
|
||||
const command = `game.ds4.macros.rollItemMacro("${itemData._id}");`;
|
||||
export async function createRollItemMacro(itemData: DS4ItemData, slot: string): Promise<void> {
|
||||
const command = `game.ds4.macros.rollItem("${itemData._id}");`;
|
||||
const macro =
|
||||
game.macros?.entities.find((m) => m.name === itemData.name && m.data.command === command) ??
|
||||
(await Macro.create(
|
||||
|
@ -30,14 +30,14 @@ export async function createItemMacro(itemData: DS4ItemData, slot: string): Prom
|
|||
* Execute the item macro for the given itemId.
|
||||
* @param itemId
|
||||
*/
|
||||
export async function rollItemMacro(itemId: string): Promise<void> {
|
||||
export async function rollItem(itemId: string): Promise<void> {
|
||||
const speaker = ChatMessage.getSpeaker();
|
||||
const actor = (getCanvas().tokens.get(speaker.token ?? "")?.actor ?? game.actors?.get(speaker.actor ?? "")) as
|
||||
| DS4Actor
|
||||
| null
|
||||
| undefined;
|
||||
if (!actor) {
|
||||
return notifications.warn(game.i18n.localize("DS4.WarningMustControlActorToRollItemMacro"));
|
||||
return notifications.warn(game.i18n.localize("DS4.WarningMustControlActorToUseRollItemMacro"));
|
||||
}
|
||||
const item = actor.items?.get(itemId);
|
||||
if (!item) {
|
Loading…
Add table
Add a link
Reference in a new issue