Accessing data in active effects via @ symbol

I noticed other systems are able to expose certain bits of data and access it in active effects eg: attribute: system.armor.ac mode: add value: @str.value However I can't seem to get the same functionality in my system. I have an actor data model module>data>actor.mjs file that just exports an actor class that extends foundry.abstract.TypeDataModel I have an actor document module>documets>actor.mjs that extends the actor data model in module>documents>actor.mjs I expose the abilities to the top level via getRollData()
getRollData() {
// Starts off by populating the roll data with a shallow copy of `this.system`
const data = { ...this.system }

// Copy the ability scores to the top level, so that rolls can use
// formulas like `@str.mod + 4`.
if (data.abilities) {
for (let [k, v] of Object.entries(data.abilities)) {
data[k] = foundry.utils.deepClone(v)
}
}

return data
}
getRollData() {
// Starts off by populating the roll data with a shallow copy of `this.system`
const data = { ...this.system }

// Copy the ability scores to the top level, so that rolls can use
// formulas like `@str.mod + 4`.
if (data.abilities) {
for (let [k, v] of Object.entries(data.abilities)) {
data[k] = foundry.utils.deepClone(v)
}
}

return data
}
However when I try and use this in an effect the value of the attribute I'm changing returns NaN I know my attribute is correct because if I change the @str.value to simply 1 I get the expected output
3 Replies
Bolts
Bolts•3mo ago
They might have a custom active effect class that adds that functionality. Check those systems to see what they do in ActiveEffect#apply
bluegreymouse
bluegreymouse•3mo ago
looking at DnD they do have a custom active effect class but I don't see anything special to replace @ values 🤔 https://github.com/foundryvtt/dnd5e/blob/04c17cd0bc90e070d7312155228945c8f269597e/module/documents/active-effect.mjs#L117-L192
GitHub
dnd5e/module/documents/active-effect.mjs at 04c17cd0bc90e070d731215...
An implementation of the 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). - foundryvtt/dnd5e
bluegreymouse
bluegreymouse•3mo ago
okay so i seem to have found it. seems like the system is doing this itself and is not a feature of foundry https://github.com/foundryvtt/dnd5e/blob/04c17cd0bc90e070d7312155228945c8f269597e/module/utils.mjs#L91-L110
GitHub
dnd5e/module/utils.mjs at 04c17cd0bc90e070d7312155228945c8f269597e ...
An implementation of the 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). - foundryvtt/dnd5e
Want results from more Discord servers?
Add your server