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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} itemData The item data
|
||||
* @param {object} item The item
|
||||
* @returns {Promise<Macro | undefined>} A promise that resolves to the created macro
|
||||
*/
|
||||
async function getOrCreateRollItemMacro(itemData) {
|
||||
const command = `game.ds4.macros.rollItem("${itemData._id}");`;
|
||||
async function getOrCreateRollItemMacro(item) {
|
||||
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) {
|
||||
return existingMacro;
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ async function getOrCreateRollItemMacro(itemData) {
|
|||
return Macro.create(
|
||||
{
|
||||
command,
|
||||
name: itemData.name,
|
||||
name: item.name,
|
||||
type: "script",
|
||||
img: itemData.img,
|
||||
img: item.img,
|
||||
flags: { "ds4.itemMacro": true },
|
||||
},
|
||||
{ renderSheet: false },
|
||||
|
|
Loading…
Reference in a new issue