Skip to content
Aedif edited this page May 31, 2025 · 2 revisions

Running the code

To run the module using npm:

  • npm install
    • npm run build or npm run watch

To run the module without npm/webpack:

  • Open module.json
    • Modify "esmodules": ["bundle/tactical-grid.js"], to point to "esmodules": ["tactical-grid.js"],

Adding module and game system support

TacticalGrid loads code related to 3rd party systems and modules dynamically.

To help maintain it please follow the structure outlined in Module support and Game System support

Module support

Create a new script file in scripts/modules/ and add hook calls, wrappers and any other code within a function of this signature:

export function register() {}

Call this function within externalSupport.js inside registerModules as so:

if (game.modules.get('module-id')?.active) import('./modules/yourModuleScript.js').then((module) => module.register());

Game System support

Create a new script file in scripts/systems/

import { GenericSystem } from './generic.js';

export default class NewGameSystem extends GenericSystem {
  /** @override */
  static onInit() {
     super.onInit()
  }

  /** @override */
  static getTokenRange(token) {
    [5];
  }

  /** @override */
  static getItemRange(item, token) {
    return [5, 10, 60];
  }

  /** @override */
  static getItemFromMacro(macro, actor) {
    return null;
  }
}

Register this new system within externalSupport.js inside registerGameSystem as so:

    case 'gameSystemId':
      gameSystem = (await import('./systems/yourSystemScript.js')).default;
      break;
  • onInit
    • Called on game 'init'
    • This is where you'd register renderActorSheetV2 hooks and any other custom logic related to the game system
  • getTokenRange
    • Override to return a range in the context of hovering over a Token
  • getItemRange
    • Override to return a range in the context of hovering over an Item
  • getItemFromMacro
    • Some game systems allow items to be dragged into the hotbar to create "item macros"
    • Override this function to process a macro into an item

RangeHighlightAPI

In majority of cases all the supporting code will want to do is call RangeHighlightAPI's rangeHighlight followed by clearRangeHighlight whenever some system or module specific element is hovered over and hoverd out.

  • Apply Range Highlight on mouseenter
    • RangeHighlightAPI.rangeHighlight
    • RangeHighlightAPI.rangeHighlightItemUuid
  • Clear Range Highlight on mouseleave
    • RangeHighlightAPI.clearRangeHighlight
    • RangeHighlightAPI.clearRangeHighlightItemUuid