Skip to content

Instantly share code, notes, and snippets.

@BoltsJ
Last active September 1, 2021 15:03
Show Gist options
  • Save BoltsJ/3165f5ded9dd49103c1752e82e458431 to your computer and use it in GitHub Desktop.
Save BoltsJ/3165f5ded9dd49103c1752e82e458431 to your computer and use it in GitHub Desktop.
/***************************************************************
* This has been deprecated and does not support lancer 1.0.0+ *
***************************************************************/
// Bar Brawl Default Config
Hooks.on("preCreateToken", function(_scene, data) {
const actor = game.actors.get(data.actorId);
data.flags.barbrawl = data.flags.barbrawl ?? {};
const token_bars = data.flags.barbrawl?.resourceBars ?? {};
let def_bars = {};
switch (actor.data.type) {
case "deployable":
def_bars = {
"bar1": {
id: "bar1",
mincolor: "#FF0000",
maxcolor: "#80FF00",
position: "bottom-inner",
attribute: "hp",
visibility: CONST.TOKEN_DISPLAY_MODES.HOVER
}
}
break;
case "pilot":
case "npc":
def_bars = {
"bar1": {
id: "bar1",
ignoreMax: false,
ignoreMin: true,
mincolor: "#FF0000",
maxcolor: "#80FF00",
position: "bottom-inner",
attribute: "mech.hp",
visibility: CONST.TOKEN_DISPLAY_MODES.HOVER
},
"bar2": {
id: "bar2",
ignoreMax: true,
ignoreMin: false,
mincolor: "#700000",
maxcolor: "#ff0000",
position: "bottom-inner",
attribute: "mech.heat",
visibility: CONST.TOKEN_DISPLAY_MODES.HOVER
}
};
break;
default:
}
data.flags.barbrawl.resourceBars = mergeObject(def_bars, token_bars);
});
@BoltsJ
Copy link
Author

BoltsJ commented Jan 15, 2021

Save this script in the directory for your game world and add the path (relative to the json file) to the esmodules array in your world.json, then edit the defaults to your preferences. Once the changes have been made, restart foundry.

Example:

{
  "name": "test",
  "title": "Test world",
  "description": "",
  "version": "1.0.0",
  "minimumCoreVersion": "0.0.0",
  "compatibleCoreVersion": "1.0.0",
  "scripts": [],
  "esmodules": [
      "./defaultbars.js"
  ],
...

More information: https://foundryvtt.wiki/en/basics/world-scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment