// старый способ добавить итем персонажу // // const compendiumPackName = 'pf2e.feature-effects'; // const effectName = 'Effect: Rage'; // const actor = game.user.character; // await pack.getEntry(effectId).then(effect => actor.createOwnedItem(effect) ); // get item from compendium to actor async function getItemFromCompendium (itemName){ const pack = game.packs.get("sc-items.sc-items"); await pack.getIndex(); const itemId = pack.index.find(e => e.name === itemName)._id; item = [await pack.getDocument(itemId)] await actor.createEmbeddedDocuments("Item", item) } // проверить что у игрока есть персонаж if (game.user.character == null){ ui.notifications.warn('Игроку не назначен персонаж'); return } let compendium = (Array.from(game.packs)).filter(element => element.metadata.name == 'sc-items') compendiumData = Array.from(compendium[0].index) compendiumData.find(element => element.name == 'Рапира/Rapier') // найти объект по имени function findItem(itemName, compendium) { let compendiumData = (Array.from(game.packs)).filter(element => element.metadata.name == compendium) compArray = Array.from(compendiumData[0].index) return compArray.find(element => element.name == itemName) } // получить класс персонажа // от класса выбрать варианты стартового снаряжения // передать выбранное снаряжение персонажу let a = `
Select items
Legend2
  • Длинный меч/Longsword
  • Рапира/Rapier
Legend3
  • Набор дипломата
  • Набор артиста
` new Dialog({ title: "Test Dialog", // content: a, template: "./templates/bard.html" buttons: { one: { icon: '', label: "Option One", callback: (html) => myCallback(html) } } } ).render(true); function myCallback(html) { // let radios = document.querySelectorAll('input[type="radio"]'); let radios = html.find('input[type="radio"]'); // let button = document.querySelector('#button'); for (let radio of radios) { if (radio.checked) { console.log(radio.value); // item = findItem(radio.value, "sc-items") // if (item == null || item == undefined){ // ui.notifications.warn(`Предмет `+radio.value+`не найден в библиотеке`); // return // } getItemFromCompendium(radio.value) // console.log(item); } } // const value = html.find("input#choise1").val(); // const array1 = [html.find('input[type="radio"]:checked').val()]; // const value = html.find('input[type="radio"]:checked').val(); // ui.notifications.info(`Value: ${value}`); // console.log(value) // console.log(array1) // return value }