From 28fb5dabdd4a18860887db6a3c6c96692344979c Mon Sep 17 00:00:00 2001 From: Ben Zhang Date: Fri, 29 Mar 2024 18:21:14 -0400 Subject: [PATCH] disallow deleting effects if not owned by actor It is easy to accidentally right-click an effect and permanantly remove it, which is usually not desireable. This disallows doing so for external effects such as ones granted by items. Right-clicking instead performs the same action as left-click, disabling the effect temporarily. --- scripts/roll-handler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index b05d467..a7eea4f 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -415,8 +415,12 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { const effects = 'find' in actor.effects.entries ? actor.effects.entries : actor.effects let effect = effects.find(effect => effect.id === actionId) + // only allow deletion if effect is directly on this actor + let internalEffect = true + // if the effect isn't directly on the actor, search all applicable effects for it if (!effect) { + internalEffect = false for (const e of actor.allApplicableEffects()) { if (e.id === actionId) { effect = e @@ -428,7 +432,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { const isRightClick = this.isRightClick(event) - if (isRightClick) { + if (isRightClick && internalEffect) { await effect.delete() } else { await effect.update({ disabled: !effect.disabled })