diff --git a/module/mosh.js b/module/mosh.js index 4b18290..7e6961e 100644 --- a/module/mosh.js +++ b/module/mosh.js @@ -66,16 +66,6 @@ Hooks.once('init', async function () { }); - /** - * Set default values for new actors' tokens - */ - Hooks.on("preCreateActor", (createData) => { - if (createData.type == "character") { - createData.token.vision = true; - createData.token.actorLink = true; - } - }) - Handlebars.registerHelper('toLowerCase', function (str) { return str.toLowerCase(); }); @@ -86,6 +76,34 @@ Hooks.once("ready", async function () { Hooks.on("hotbarDrop", (bar, data, slot) => createMothershipMacro(data, slot)); }); +/** + * Set default values for new actors' tokens + */ +Hooks.on("preCreateActor", (createData) => { + let disposition = CONST.TOKEN_DISPOSITIONS.NEUTRAL; + + if (createData.type == "creature") { + disposition = CONST.TOKEN_DISPOSITIONS.HOSTILE + } + + // Set wounds, advantage, and display name visibility + mergeObject(createData, + { + "token.bar1": { "attribute": "health" }, // Default Bar 1 to Health + "token.bar2": { "attribute": "hits" }, // Default Bar 2 to Insanity + "token.displayName": CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER, // Default display name to be on owner hover + "token.displayBars": CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER, // Default display bars to be on owner hover + "token.disposition": disposition, // Default disposition to neutral + "token.name": createData.name // Set token name to actor name + }) + + + if (createData.type == "character") { + createData.token.vision = true; + createData.token.actorLink = true; + } +}) + /* -------------------------------------------- */ /* Hotbar Macros */ @@ -169,8 +187,8 @@ function rollStatMacro() { let actor; if (speaker.token) actor = game.actors.tokens[speaker.token]; if (!actor) actor = game.actors.get(speaker.actor); - const stat = actor ? Object.entries(actor.data.data.stats) : null; - + const stat = actor ? Object.entries(actor.data.data.stats) : null; + // if (stat == null) { // ui.notifications.info("Stat not found on token"); diff --git a/template.json b/template.json index 0cdcdb8..014e797 100644 --- a/template.json +++ b/template.json @@ -41,11 +41,11 @@ "value": "" }, "xp": { - "value": 1 + "value": 0 }, "attributes": { "level": { - "value": 1 + "value": 0 } }, "stats": {