module/dcc.js
/**
 * Create a Macro from an weapon 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 weapon 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 weapon 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 createDCCWeaponMacro(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.dcc.rollDCCWeaponMacro("${item.id}");`;
    let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
    let img = '/systems/mcc/styles/images/axe-square.png';
    if (item.id[0] === 'r') {
        img = '/systems/mcc/styles/images/bow-square.png';
    }
    if (!macro) {
        macro = await Macro.create({
            name: item.name,
            type: "script",
            img: img,
            command: command,
            flags: {"dcc.itemMacro": true}
        });
    }
    game.user.assignHotbarMacro(macro, slot);
    return false;
}
async function createDCCWeaponMacro ( 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 . id } ` ; let macro = game . macros . entities . find ( m => ( m . name === item . name ) && ( m . command === command ) ) ; let img = '/systems/mcc/styles/images/axe-square.png' ; if ( item . id [ 0 ] === 'r' ) { img = '/systems/mcc/styles/images/bow-square.png' ; } if ( ! macro ) { macro = await Macro . create ( { name : item . name , type : "script" , img : img , command : command , flags : { "dcc.itemMacro" : true } } ) ; } game . user . assignHotbarMacro ( macro , slot ) ; return false ; }
Create a Macro from an weapon drop.
Create a Macro from an weapon drop .
// Create the macro command