feat(HealthColors): upgrade to v2.0.0 and refactor for improved stability#2202
Open
steverobertsuk wants to merge 17 commits intoRoll20:masterfrom
Open
feat(HealthColors): upgrade to v2.0.0 and refactor for improved stability#2202steverobertsuk wants to merge 17 commits intoRoll20:masterfrom
steverobertsuk wants to merge 17 commits intoRoll20:masterfrom
Conversation
…lity Upgrade the script to version 2.0.0, performing a major modernisation refactor. This update ensures the script respects manual visual overrides by only triggering on health changes, removes the Underscore.js dependency, and adds JSDoc documentation to improve long-term maintainability. Fixes bugs where aura2 does not show, especially when changing health values. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…onfig function. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
Increment SCHEMA_VERSION from 1.0.3 to 1.1.0 to track incremental state migrations in the v2.0.0 line. Update UPDATED timestamp to 2026-04-09. Fix two adjacent JSDoc spellings (behaviour, colours) in the same hunk. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
Replace colour/colours with color/colors, artefacts with artifacts, and specialised with specialized throughout JSDoc and inline comments. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…lt color
Add five new keys to DEFAULTS:
Aura1Shape ("Circle"), Aura1Color ("00FF00"),
Aura2Size (5), Aura2Shape ("Square"), Aura2Color ("806600").
Change the default HealFX color from 00FF00 to FDDC5C (gold) for better
visual contrast in the default heal particle effect.
Update JSDoc for the DEFAULTS object to document all new properties.
Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…olor key aliases Replace placeholder FX_PARAM_DEFAULTS values (size 100, emissionRate 100, opaque white start color, zero speed) with production-ready values that render more clearly in-game: size 15, lifeSpan 50, emissionRate 10, speed 1, neutral grey start color [128,128,128,1]. Add both British (startColour/endColour) and American (startColor/endColor) property aliases and their Random counterparts so the defaults object is safe to spread regardless of which key variant the Roll20 sandbox or caller uses. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…s in spawnFX Add spawnFx to the global script declaration so the sandbox linter recognises its use in the new fallback spawn path. Improve hexToRgb: strip leading "#" and whitespace before regex match, and log a warning when a non-empty invalid hex string is received. Add getFxDefinition(fxObj): safely reads and deep-clones a Roll20 custfx definition, handling both string-JSON and plain-object return forms. Revamp spawnFX to pick the correct start/end color from the incoming fx partial first, then the merged defaults, checking both British (startColour) and American (startColor) key variants. Pass both aliases to spawnFxWithDefinition so the definition is valid regardless of what the Roll20 client expects. Also neutralize all random color channels. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…helpers Add normalizeHex6(value, fallback): strips "#" and whitespace, upper-cases, and validates a 6-digit hex string, returning the fallback on invalid input. Add normalizeShape(value, fallback): normalizes a shape label to "Circle" or "Square", returning the fallback for any other input. Both helpers are used by the new !aura a1tint, !aura a2tint, !aura a1shape, and !aura a2shape command handlers to validate user-supplied values. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
Add buildDefaultFxDefinition(isHeal, baseDef): builds a normalized color and particle payload for default heal/hurt custfx objects, applying tuned values (maxParticles 220/size 12/lifeSpan 40 for heal; 200/10/22 for hurt) and neutralizing all random color channels. Add syncDefaultFxObjects(): applies current HealFX/HurtFX colors and profile tuning to the campaign -DefaultHeal/-DefaultHurt custfx objects immediately. Called from checkInstall so definitions are correct on first load and whenever FX color settings change. Add resetDefaultFxObjects(): removes stale default custfx objects and recreates them via checkInstall; backs the !aura reset-fx command. Add resetAllSettingsToDefaults() and runResetAllFlow(): restore all state to DEFAULTS, rebuild default FX, and force-sync all tokens; backs !aura reset-all. Document the optional update parameter in the getBarHealth JSDoc. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…d fallback
Refactor buildFXList to use getFxDefinition instead of calling
.get("definition") directly. In all code paths (heal, default hurt, custom
hurt), set both startColour/startColor and endColour/endColor to the
resolved RGB and neutralize all random color channels. This prevents
grey/white fallback artifacts from missing color key variants.
Add spawnDefaultFxById(obj, isHeal, useBlood): a fallback spawn path that
spawns the default custfx by ID using spawnFx(), bypassing
spawnFxWithDefinition color inconsistencies seen in some Roll20
sandbox/client combinations for default heal/hurt effects.
Call spawnDefaultFxById as an early exit in triggerFX before the
definition-based path so default heal/hurt visuals are consistent.
Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…eAll scope In handleToken, check whether the configured health bar has a max value before processing. If bar_max is empty, call clearAuras and return early, preventing stale health indicators on tokens without a configured bar. In menuForceUpdate, remove the filter that restricted the work queue to tokens with a populated bar_max and bar_value. All tokens on the objects layer are now included so the re-evaluation (including clearing auras on unconfigured tokens) runs for the full map. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
Add makePill(label, extraStyle): a styled non-interactive span element for read-only display in the settings snapshot panel, styled to match the GM menu look but without a clickable action. Add showSettingsInGameChat(): renders the complete current settings as a public game-chat panel using makePill elements so all players and the GM can see active configuration. Includes colored boolean indicators, FX color swatches, and Aura 1/2 detail rows backed by the new state keys. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
… labels
In showMenu:
- Rename "Bar:" to "Health Bar:" for clarity.
- Add Aura 1 Radius (ft) units suffix.
- Add Aura 1 Shape and Aura 1 Color (Tint) interactive buttons backed by
the new !aura a1shape and !aura a1tint commands.
- Add Aura 2 Radius (ft), Aura 2 Shape, and Aura 2 Color (Tint) buttons
backed by !aura a2size, !aura a2shape, and !aura a2tint commands.
- Update HealFX Color default hint in the button URL to FDDC5C to match
the new default.
- Add aura1Style / aura2Style variables for colored button backgrounds.
Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…n, Aura1/2 commands, and post-change snapshot Split !aura on/off into two explicit cases so on always enables and off always disables, replacing the previous toggle on the on case. Add input validation for !aura bar: accepts only 1, 2, or 3; whispers confirmation and immediately calls menuForceUpdate on a valid change; whispers a clear error on an invalid value. Add new Aura 1/2 commands: !aura a1shape, !aura a1tint, !aura a2size, !aura a2shape, !aura a2tint — each validated through normalizeShape or normalizeHex6 before updating state. Add !aura reset-fx and !aura reset-all recovery commands backed by resetDefaultFxObjects and runResetAllFlow respectively. Add !aura settings to output the current settings snapshot on demand. Introduce a changedSetting flag: when any setting changes, call showSettingsInGameChat instead of showMenu to post a single read-only snapshot to game chat; non-mutating commands still show the GM menu. Call syncDefaultFxObjects immediately after HEAL and HURT color changes. Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
CHANGELOG (v2.0.0 section):
- Added entries for !aura reset-fx, !aura reset-all, !aura settings,
Aura 1/2 detail commands, public settings snapshot, and !aura on/off
semantics change. Bumped schema version entry to 1.1.0.
- Added Fixed entries for FX color assignment, random channel
neutralization, spawnFx fallback path, particle profile tuning,
BAR validation, empty bar_max handling, Aura 1/2 output rows,
settings output deduplication, and proactive FX definition sync.
README:
- Document !aura settings, !aura a1shape/a1tint/a2size/a2shape/a2tint,
!aura reset-fx, and !aura reset-all commands.
- Update !aura bar description to include immediate token sync behavior.
- Update !aura heal default hint to FDDC5C.
- Add note about Aura 1/2 detail rows in settings output.
- Note that setting changes post a single game-chat snapshot.
- Add troubleshooting notes for FX rendering variance and missing
bar max value.
Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
…l20 profile links of authors Signed-off-by: Steve Roberts <steve@shadowcomputers.co.uk>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Major modernization and stability refactor of the entire script, consolidating performance improvements, critical bug fixes, and new user control features. This version represents a complete overhaul from the v1.6.x series.
Added
AuraSize) to indicate stability.!aura reset-fx(rebuild default heal/hurt custom FX objects) and!aura reset-all(restore all settings to defaults + rebuild default FX + force update).!auracommands now post a read-only settings panel to game chat for table visibility.!aura a1shape,!aura a1tint,!aura a2size,!aura a2shape, and!aura a2tintto adjust displayed Aura 1/Aura 2 detail values from chat.!aura settingsto post the current settings snapshot to game chat on demand.Changed
_(Underscore) dependency — no longer required.buttonColorfunction — legacy function completely removed afterverifying no external or internal dependencies; superseded by
nameBtn.(UseBlood !== "OFF" || UseBlood !== "NO").!aura on/offsemantics — now explicitly sets global enabled state instead of toggling onon.1.1.0to reflect incremental state/data migration changes in the v2.0.0 line.Fixed
checkInstallandhandleTokenthroughout.OneOffstate key to preventundefinedcollisions.playDeathto ensure jukebox tracks are properly stopped before restarting.startColour/startColorandendColour/endColorconsistently, preventing gray/white fallback artifacts.spawnFx) when definition-based spawning renders colors inconsistently.!aura barnow validates1|2|3, whispers confirmation on change, and immediately runs a full sync to apply the new bar selection.maxvalue on the configured bar now have aura/tint cleared, preventing stale health indicators.Aura2Size,Aura2Shape,Aura2Color) instead of hardcoded labels.Aura1Shape,Aura1Color).Signed-off-by: Steve Roberts steve@shadowcomputers.co.uk