From 74d881c3df40dd5f425b9b429d83558ef8e8a9f5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 2 May 2026 18:56:23 -0600 Subject: [PATCH] Fix a bug where the actor context was not being correctly called unless the user had an actor assigned to them --- module/data/Item/attribute.mjs | 9 ++++++++- module/data/Item/generic.mjs | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/module/data/Item/attribute.mjs b/module/data/Item/attribute.mjs index 6c83a9d..1bb65c1 100644 --- a/module/data/Item/attribute.mjs +++ b/module/data/Item/attribute.mjs @@ -162,7 +162,14 @@ export class AttributeItemData extends foundry.abstract.TypeDataModel { }); }; - await macro?.execute({ item: this.parent }); + // Get the speaker so that Foundry has the correct context to be able to call + // the Actor's getData method, letting us augment the context dynamically for + // the @active roll context + const speaker = foundry.documents.ChatMessage.implementation.getSpeaker({ + actor: this.parent.parent + }); + + await macro?.execute({ item: this.parent, speaker }); }; // #endregion Methods }; diff --git a/module/data/Item/generic.mjs b/module/data/Item/generic.mjs index 6552f19..5c0b8db 100644 --- a/module/data/Item/generic.mjs +++ b/module/data/Item/generic.mjs @@ -84,6 +84,13 @@ export class GenericItemData extends foundry.abstract.TypeDataModel { }); }; + // Get the speaker so that Foundry has the correct context to be able to call + // the Actor's getData method, letting us augment the context dynamically for + // the @active roll context + const speaker = foundry.documents.ChatMessage.implementation.getSpeaker({ + actor: this.parent.parent + }); + await macro?.execute({ item: this.parent }); }; // #endregion Methods