anvil-vtt / FateX

FateX is the extended Fate game system for FoundryVTT.
MIT License
22 stars 16 forks source link

Make some token settings configurable #53

Open saif-ellafi opened 3 years ago

saif-ellafi commented 3 years ago

Along making the token take an appropriate name, rather than the templates. It would also be great to configure the display visibility.

Hopefully this example helps

    game.settings.register("dark-heresy", "defaultTokenDisplay", {
        name: "Default token name display mode",
        hint: "Choose default behavior on hovering on token names.",
        scope: "world",
        config: true,
        type: String,
        default: CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER,
        choices: {
          [CONST.TOKEN_DISPLAY_MODES.NONE]: "Never Displayed",
          [CONST.TOKEN_DISPLAY_MODES.CONTROL]: "When Controlled",
          [CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER]: "Hovered by Owner",
          [CONST.TOKEN_DISPLAY_MODES.HOVER]: "Hovered by Anyone",
          [CONST.TOKEN_DISPLAY_MODES.OWNER]: "Always for Owner",
          [CONST.TOKEN_DISPLAY_MODES.ALWAYS]: "Always for Everyone"
        }
    });
Hooks.on("preCreateActor", (createData) => {
    mergeObject(createData, {
        "token.bar1" :{ "attribute" : "wounds" },
        "token.bar2" :{ "attribute" : "fatigue" },
        "token.displayName" : game.settings.get('dark-heresy', 'defaultTokenDisplay'),
        "token.displayBars" : CONST.TOKEN_DISPLAY_MODES.ALWAYS,
        "token.disposition" : CONST.TOKEN_DISPOSITIONS.NEUTRAL,
        "token.name" : createData.name
    });
    if (createData.type === "acolyte") {
        createData.token.vision = true;
        createData.token.actorLink = true;
    }
});