async function createPTUMacro(data, slot) {
  if (data.type !== "Item") return;
  if (!("data" in data)) return ui.notifications.warn("You can only create macro buttons for owned Items");
  const item = data.data;

  // Create the macro command
  const command = `game.ptu.rollItemMacro("${item.name}");`;
  let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
  if (!macro) {
    macro = await Macro.create({
      name: item.name,
      type: "script",
      img: item.img,
      command: command,
      flags: { "ptu.itemMacro": true }
    });
  }
  game.user.assignHotbarMacro(macro, slot);
  return false;
}
/**
 * Create a Macro from an Item drop.
 * Get an existing item macro if one exists, otherwise create a new one.
 * @param {Object} data     The dropped data
 * @param {number} slot     The hotbar slot to use
 * @returns {Promise}
 */
Create a Macro from an Item drop.
Get an existing item macro if one exists, otherwise create a new one.
@param {Object} data     The dropped data
@param {number} slot     The hotbar slot to use
@returns {Promise}
Create a Macro from an Item drop . Get an existing item macro if one exists otherwise create a new one . @param { Object } data The dropped data @param { number } slot The hotbar slot to use @returns { Promise }
async function createPTUMacro(data, slot) {
  if (data.type !== "Item") return;
  if (!("data" in data)) return ui.notifications.warn("You can only create macro buttons for owned Items");
  const item = data.data;
  const command = `game.ptu.rollItemMacro("${item.name}");`;
  let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
  if (!macro) {
    macro = await Macro.create({
      name: item.name,
      type: "script",
      img: item.img,
      command: command,
      flags: { "ptu.itemMacro": true }
    });
  }
  game.user.assignHotbarMacro(macro, slot);
  return false;
}
async function createPTUMacro ( data , slot ) { if ( data . type !== "Item" ) return ; if ( ! ( "data" in data ) ) return ui . notifications . warn ( "You can only create macro buttons for owned Items" ) ; const item = data . data ; const command = ` ${ item . name } ` ; let macro = game . macros . entities . find ( m => ( m . name === item . name ) && ( m . command === command ) ) ; if ( ! macro ) { macro = await Macro . create ( { name : item . name , type : "script" , img : item . img , command : command , flags : { "ptu.itemMacro" : true } } ) ; } game . user . assignHotbarMacro ( macro , slot ) ; return false ; }
Create a Macro from an Item drop.
Create a Macro from an Item drop .
// Create the macro command