Foundry VTT - TOR 2e Random Encounters Module

mail@pastecode.io avatar
unknown
html
2 years ago
2.2 kB
3
Indexable
Never
MACRO NAME: Random Encounters
MACRO TYPE: script

// copy and paste from below this line:
let message;
async function printMessage(table) {
    let roll = await table.roll()
    let result = roll.results[0];
    let chatData = {
        content: `<div style="text-align:center">${result.data.text}</div>`,
        whisper: [game.user],
    };
    ChatMessage.create(chatData, {});
}

let dType = new Dialog({
    title: "Random Encounters",
    content: `<div style="text-align:center;font-size:24px;"><h3>Which region?<\h3><h2><\h2><\div>`,
    buttons: {
        button1: { 
            label: "Chetwood",
            callback: () => {
                message = "Chetwood";
                printMessage(
                    game.tables.contents
                        .find((t) => t.name === "Encounters-Chetwood")
                );
            },
        },
        button2: { 
            label: "East Rd",
            callback: () => {
                message = "East Road";
                printMessage(
                    game.tables.contents
                        .find((t) => t.name === "Encounters-EastRoad")
                );
            },
        },
        button3: {
            label: "Greenway",
            callback: () => {
                message = "Greenway";
                printMessage(
                    game.tables.contents
                        .find((t) => t.name === "Encounters-Greenway")
                );
            },
        },
        button4: {
            label: "N.Downs",
            callback: () => {
                message = "North Downs";
                printMessage(
                    game.tables.contents
                        .find((t) => t.name === "Encounters-NorthDowns")
                );
            },
        },
        button5: {
            label: "Trollshaws",
            callback: () => {
                message = "Trollshaws";
                printMessage(
                    game.tables.contents
                        .find((t) => t.name === "Encounters-Trollshaws")
                );
            },
        },
    },
}).render(true);