Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define the list of status macros we are interested in
- const statusMacros = [
- "Fire",
- "Poison",
- "Bleed",
- "Freeze",
- "Staggered",
- "Intoxication",
- "Hallucination",
- "Nausea",
- "Regeneration",
- "Remove Effects",
- "Suffocation",
- "Blinded"
- ];
- // Function to display macros as a GUI
- async function showMacroSelector() {
- // Filter macros to only include the ones listed in statusMacros
- const allMacros = Array.from(game.macros.values());
- const statusMacrosList = allMacros.filter(macro => statusMacros.includes(macro.name));
- // Sort the macros alphabetically by name
- statusMacrosList.sort((a, b) => a.name.localeCompare(b.name));
- // Create an HTML container to display the macros
- const content = `
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 10px; padding: 10px;">
- ${statusMacrosList.map(macro => `
- <div style="text-align: center; display: flex; flex-direction: column; align-items: center;">
- <img src="${macro.img}" style="cursor: pointer; width: 64px; height: 64px;" title="${macro.name}" data-macro-id="${macro.id}" />
- <div>${macro.name}</div>
- </div>
- `).join('')}
- </div>
- `;
- // Create a dialog to hold the GUI
- const dialog = new Dialog({
- title: "Select a Status Macro",
- content: content,
- buttons: {},
- render: (html) => {
- // Add click event listener to all images
- html.find('img').on('click', async (event) => {
- const macroId = event.currentTarget.dataset.macroId;
- const macro = game.macros.get(macroId);
- if (macro) {
- // Execute the selected macro
- await macro.execute();
- // Close the dialog after executing the macro
- dialog.close();
- } else {
- console.error(`Macro with ID ${macroId} not found.`);
- }
- });
- }
- });
- // Render the dialog
- dialog.render(true);
- }
- // Execute the macro selector function
- showMacroSelector();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement