Fixed Token Default Settings -0.1.3b

This commit is contained in:
Martin Jencka
2020-11-29 09:03:22 -07:00
parent d9a3b4c7d6
commit 6a4bc362b1
2 changed files with 32 additions and 14 deletions
+30 -12
View File
@@ -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");
+2 -2
View File
@@ -41,11 +41,11 @@
"value": ""
},
"xp": {
"value": 1
"value": 0
},
"attributes": {
"level": {
"value": 1
"value": 0
}
},
"stats": {