Last active
September 8, 2025 20:37
-
-
Save tradiuz/37a1a168900afa6d33d80fc1953031ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| MoSh Bar Brawl Config | |
| Create a _script_ macro and past this into the contents. | |
| Run the macro and it'll set the config for bar brawl and update all resources already deployed. | |
| - tradiuz | |
| */ | |
| const characterBars = { | |
| "bar1": { | |
| "order": 1, | |
| "id": "bar1", | |
| "attribute": "hits", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#AA0000", | |
| "position": "bottom-inner", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": 75, | |
| "shareHeight": true, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": true, | |
| "invertDirection": true, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar2": { | |
| "order": 0, | |
| "id": "bar2", | |
| "attribute": "health", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#80FF00", | |
| "position": "bottom-inner", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": 25, | |
| "indentRight": null, | |
| "shareHeight": true, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": false, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar3": { | |
| "order": 2, | |
| "id": "bar3", | |
| "attribute": "other.stress", | |
| "mincolor": "#000080", | |
| "maxcolor": "#80B3FF", | |
| "position": "bottom-outer", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": null, | |
| "shareHeight": false, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": true, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar4": { | |
| "order": 3, | |
| "id": "bar4", | |
| "attribute": "netHP", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#00FF00", | |
| "position": "bottom-inner", | |
| "otherVisibility": 50, | |
| "ownerVisibility": 0, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": null, | |
| "shareHeight": false, | |
| "style": "none", | |
| "label": "", | |
| "invert": false, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar5": { | |
| "order": 4, | |
| "id": "bar5", | |
| "attribute": "other.stress", | |
| "mincolor": "#FF00FF", | |
| "maxcolor": "#0000FF", | |
| "position": "bottom-outer", | |
| "otherVisibility": 50, | |
| "ownerVisibility": 0, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": null, | |
| "shareHeight": false, | |
| "style": "none", | |
| "label": "", | |
| "invert": true, | |
| "invertDirection": false, | |
| "subdivisions": 5, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| } | |
| } | |
| const creatureBars = { | |
| "bar1": { | |
| "order": 1, | |
| "id": "bar1", | |
| "attribute": "hits", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#AA0000", | |
| "position": "bottom-inner", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": 75, | |
| "shareHeight": true, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": true, | |
| "invertDirection": true, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar2": { | |
| "order": 0, | |
| "id": "bar2", | |
| "attribute": "health", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#80FF00", | |
| "position": "bottom-inner", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": 25, | |
| "indentRight": null, | |
| "shareHeight": true, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": false, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar3": { | |
| "order": 2, | |
| "id": "bar3", | |
| "attribute": "other.stress", | |
| "mincolor": "#000080", | |
| "maxcolor": "#80B3FF", | |
| "position": "bottom-outer", | |
| "otherVisibility": 0, | |
| "ownerVisibility": 50, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": null, | |
| "shareHeight": false, | |
| "style": "fraction", | |
| "label": "", | |
| "invert": true, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| }, | |
| "bar4": { | |
| "order": 3, | |
| "id": "bar4", | |
| "attribute": "netHP", | |
| "mincolor": "#FF0000", | |
| "maxcolor": "#00FF00", | |
| "position": "bottom-inner", | |
| "otherVisibility": 50, | |
| "ownerVisibility": 0, | |
| "gmVisibility": -1, | |
| "hideFull": false, | |
| "hideEmpty": false, | |
| "hideCombat": false, | |
| "hideNoCombat": false, | |
| "hideHud": false, | |
| "indentLeft": null, | |
| "indentRight": null, | |
| "shareHeight": false, | |
| "style": "none", | |
| "label": "", | |
| "invert": false, | |
| "invertDirection": false, | |
| "subdivisions": null, | |
| "subdivisionsOwner": false, | |
| "fgImage": "", | |
| "bgImage": "", | |
| "opacity": null | |
| } | |
| } | |
| const shipBars = {} | |
| const barConfig = game.settings.get("barbrawl", "defaultTypeResources") ?? {}; | |
| barConfig['character'] = characterBars; | |
| barConfig['creature'] = creatureBars; | |
| barConfig['ship'] = shipBars; | |
| await game.settings.set("barbrawl", "defaultTypeResources", barConfig); | |
| await Promise.all( | |
| game.actors.map(a => { | |
| let barSettings; | |
| switch (a.type) { | |
| case 'character': | |
| barSettings = characterBars; | |
| break; | |
| case 'creature': | |
| barSettings = creatureBars; | |
| break; | |
| case 'ship': | |
| barSettings = shipBars; | |
| break; | |
| default: | |
| barSettings = creatureBars; | |
| break; | |
| } | |
| let target; | |
| const v = game.version | |
| if (v < "12" && v >= "11") { | |
| target = a | |
| } else if (v >= "12") { | |
| target = a.prototypeToken | |
| } | |
| // Get existing flags to preserve them | |
| const existingFlags = target.flags || {}; | |
| // Update the actor while preserving the flags | |
| return target.update({ | |
| flags: { | |
| ...existingFlags, // Merge existing flags | |
| barbrawl: { | |
| ...existingFlags.barbrawl, | |
| resourceBars: barSettings | |
| } | |
| } | |
| }, { 'diff': false, 'recursive': false }); | |
| }) | |
| ); | |
| // Reset the bars on all existing tokens | |
| await Promise.all( | |
| game.scenes.map(s => { | |
| const updates = s.tokens.filter(t => t.actor).map(t => { | |
| let barSettings; | |
| // Determine which bar settings to use based on token's actor type | |
| switch (t.actor.type) { | |
| case 'character': | |
| barSettings = characterBars; | |
| break; | |
| case 'creature': | |
| barSettings = creatureBars; | |
| break; | |
| case 'ship': | |
| barSettings = shipBars; | |
| break; | |
| default: | |
| barSettings = creatureBars; | |
| break; | |
| } | |
| return { | |
| _id: t.id, | |
| flags: { | |
| ...t.flags, // Preserve existing token flags | |
| barbrawl: { | |
| ...t.flags?.barbrawl, | |
| resourceBars: barSettings | |
| } | |
| } | |
| }; | |
| }); | |
| return s.updateEmbeddedDocuments("Token", updates, { 'diff': false, 'recursive': false }); | |
| }) | |
| ); | |
| ui.notifications.info("Done"); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Owner view:

Entry fields on right click:

Red - Wounds, Green - HP, Blue - Sanity
Everyone view:
