This is a module for Foundry Virtual Tabletop that adds a "uses" counter to item macros on your hotbar.
This module currently only works with the DnD5e system. It shows uses for any macro created by dragging an inventory item, spell, or feat from a character sheet into the hotbar.
Uses that are shown include...
- Weapons with a Resource Consumption
- Consumables
- Features with uses
- Spells (Pact slots, Level slots, and at-will with uses)
If an item has 0 uses left, or if the currently controlled actor doesn't have the item for a macro, the macro will have no number, a red outline, and appear slightly dimmed.
If an item has no uses (ex. weapons without a resource consumption), or if a macro is not an item macro, its appearance is left unchanged.
For those who create more complicated macros, you can add a Uses counter by adding a comment to your macro's command. There are a few varieties of comments that this module will recognize...
- Equivalent Commands
- Actor and Item ID matching
- Item Name matching (optionally further filtered by Actor Name and/or Item Type)
// HotbarUses: {some other command}
This will cause the uses to be calculated as if the command were the {some other command}
value. For example, if you are using the Better Rolls and Furnace modules, and have a special "useMultipleCharges" Furnace macro that will prompt the number of points to use, and then effectively call BetterRolls.quickRollById
, you could have a macro that looks like this:
// HotbarUses: BetterRolls.quickRollById("pzGA6GqAoSsQWY0L", "Em91Iu07HkLAWAfK");
let macro = game.macros.getName("useMultipleCharges")
macro.execute("pzGA6GqAoSsQWY0L", "Em91Iu07HkLAWAfK")
// HotbarUses5e: ActorID="X" ItemID="Y"
This will cause the uses to be calculated for the actor with ID "X" and the item with ID "Y". For example, if you have a Paladin with an ID of "pzGA6GqAoSsQWY0L", and their "Lay on Hands" item has an ID of "Em91Iu07HkLAWAfK", it will show the uses left for "Lay on Hands".
// HotbarUses5e: ActorID="pzGA6GqAoSsQWY0L" ItemID="Em91Iu07HkLAWAfK"
CoolLayOnHandsMod.layOnHands("pzGA6GqAoSsQWY0L");
// HotbarUses5e: ItemName="Y"
// HotbarUses5e: ActorName="X" ItemName="Y"
// HotbarUses5e: ItemName="Y" ItemType="Z"
// HotbarUses5e: ActorName="X" ItemName="Y" ItemType="Z"
This will cause the uses to be calculated for an item with the name of "Y". If ActorName is specified, it will be for that actor. If ActorName is not specified, it will be for the currently selected actor. If ItemType is specified, it will only match items with the specified type.the actor with ID "X" and the item with ID "Y". For example, if you had a macro that caused Sally to cast Goodberry, and Sally also had both a Spell named Goodberry and an Inventory item named Goodberry, you would want...
// HotbarUses5e: ActorName="Sally" ItemName="Goodberry" ItemType="spell"
CoolGoodberyMod.castGoodberry("Sally");
Some modules modify item macros, which will cause this module to appear to not work. If you notice this, please open an issue with the full Command string for the macro that doesn't show counts and, if you know it, the name of the module that caused the macro to be created.
If you are a module author, you can add support right in your own module by adding a regular expression to this module's config (CONFIG.illandril.hotbarUses.macros.dnd5e
). Example:
Hooks.once('init', () => {
const hotbarUsesMacros = getProperty(CONFIG, 'illandril.hotbarUses.macros.dnd5e');
hotbarUsesMacros && hotbarUsesMacros.push(/^\s*BetterRolls\s*\.\s*quickRollByName\s*\(\s*(?<q>["'`])(?<actorName>.+)\k<q>\s*,\s*(?<qb>["'`])(?<itemName>.+)\k<qb>\s*\)\s*;?\s*$/);
});
The regular expression should match against your module's macros, with one or more of the following named capture groups: itemName
, itemType
, itemID
, actorID
, actorName
. I can provide assistance in creating an appropriate regular expression if necessary.
- Open the Configuration and Setup for your FoundryVTT server
- Open the Add-on Modules Tab
- Click the Install Module button
- In the Manifest URL input, specify https://github.com/illandril/FoundryVTT-hotbar-uses/releases/latest/download/module.json
- Click Install
- Launch your world
- Log in as the GM
- Open the Settings tab
- Click Manage Modules
- Check the checkbox for Illandril's Hotbar Uses