fix: fix item macro creating via drag & drop
This commit is contained in:
parent
8f941aa565
commit
c2275017f8
1 changed files with 7 additions and 7 deletions
|
@ -29,18 +29,18 @@ export async function createRollItemMacro(data, slot) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const macro = await getOrCreateRollItemMacro(itemData);
|
const macro = await getOrCreateRollItemMacro(item);
|
||||||
await getGame().user?.assignHotbarMacro(macro ?? null, slot);
|
await getGame().user?.assignHotbarMacro(macro ?? null, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {object} itemData The item data
|
* @param {object} item The item
|
||||||
* @returns {Promise<Macro | undefined>} A promise that resolves to the created macro
|
* @returns {Promise<Macro | undefined>} A promise that resolves to the created macro
|
||||||
*/
|
*/
|
||||||
async function getOrCreateRollItemMacro(itemData) {
|
async function getOrCreateRollItemMacro(item) {
|
||||||
const command = `game.ds4.macros.rollItem("${itemData._id}");`;
|
const command = `game.ds4.macros.rollItem("${item.id}");`;
|
||||||
|
|
||||||
const existingMacro = getGame().macros?.find((m) => m.name === itemData.name && m.data.command === command);
|
const existingMacro = getGame().macros?.find((m) => m.name === item.name && m.command === command);
|
||||||
if (existingMacro) {
|
if (existingMacro) {
|
||||||
return existingMacro;
|
return existingMacro;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ async function getOrCreateRollItemMacro(itemData) {
|
||||||
return Macro.create(
|
return Macro.create(
|
||||||
{
|
{
|
||||||
command,
|
command,
|
||||||
name: itemData.name,
|
name: item.name,
|
||||||
type: "script",
|
type: "script",
|
||||||
img: itemData.img,
|
img: item.img,
|
||||||
flags: { "ds4.itemMacro": true },
|
flags: { "ds4.itemMacro": true },
|
||||||
},
|
},
|
||||||
{ renderSheet: false },
|
{ renderSheet: false },
|
||||||
|
|
Loading…
Reference in a new issue