Repository navigation
1.5.0
🔌 API for other plugins
Roll for Initiative now has a public API, so other plugins (like a GM screen) can work with it:
const ri = app.plugins.plugins["roll-initiative"]?.api;ri.version: the plugin version ("1.5.0")ri.getState(sourcePath?, id?): the full state of the active fight, or of a given fight:- round,
running/ended, the current combatant and who acts next; - every combatant's initiative, HP, AC, conditions, side, hidden / disabled status and group info
- round,
ri.newCombat({ kind?, players? }): opens the New combat window. It resolves with the new encounter note's path and block id, or with the initiative text, ornullif the window was closed.ri.addCombatant("3x [[Imp]]", target?): adds creatures with the normal block syntax. In a running fight, they're rolled and sorted into the order.ri.rollInitiative(),ri.endCombat(),ri.showOnPlayerScreen(): the same as the buttons and commandsri.getActive(),ri.next(),ri.previous(): unchanged
🎲 Dice hook
ri.setRoller({ rollMany }) lets another plugin make the tracker's dice rolls, so they can show up in its own dice tray.
- Initiative rolls: Roll initiative, the single Roll +X button, the dice button in the player-initiative window, and creatures joining a running fight.
- Rolled HP: the Roll monster HP setting and the encounter card's Roll for HP.
- One batch: rolling for everyone sends a single
rollManycall, so all the dice are thrown together. Group initiative is respected. - Safe fallback: if the other plugin fails, returns bad values or takes longer than 15 seconds, the built-in dice take over. A fight never gets stuck.
📣 Events
roll-initiative:changenow carries the full fight state. It also fires when a fight ends and when the active fight switches.- New
roll-initiative:createdevent when the New combat window creates an encounter note or initiative