Active Effect Help

And it should be the actual ActiveEffect document for the effect, not just the id. I don't have the brain right now to figure out the best way to get that.
10 Replies
Ethck
Ethck3y ago
I really thought I could figure it out, but the updates just aren't going through. Here is the current state of the macro:
console.log(args);
if(args[0] === "each"){
let effect = args[2].efData.document; //the active effect which adds the AC bonus
//the Item for Armor of Agathys, set up as innate spellcasting with 0/1 uses.
let armorOfAgathys = game.items.getName("Armor of Agathys");
let bonus = parseInt(effect.data.changes[1].value);
if(bonus < 6){
console.log(effect.data.changes[1].value, effect);
effect.update({"data.changes[1].value": bonus+3});
} else {
armorOfAgathys.update({"data.uses.value": 1});
}
}
console.log(args);
if(args[0] === "each"){
let effect = args[2].efData.document; //the active effect which adds the AC bonus
//the Item for Armor of Agathys, set up as innate spellcasting with 0/1 uses.
let armorOfAgathys = game.items.getName("Armor of Agathys");
let bonus = parseInt(effect.data.changes[1].value);
if(bonus < 6){
console.log(effect.data.changes[1].value, effect);
effect.update({"data.changes[1].value": bonus+3});
} else {
armorOfAgathys.update({"data.uses.value": 1});
}
}
Some stuff still needs to be adjusted.
Ethck
Ethck3y ago
DAE list:
No description
Ethck
Ethck3y ago
(I don't think it pings on thread creation??? So just throwing out a ping. Sorry if it actually did! @badideasbureau
Daniel Thorp
Daniel Thorp3y ago
Maybe you need to await the updates?
Ethck
Ethck3y ago
I thought that as well but tried it and no dice :( The problem (as far as I understand it) is that the effect.update is not going through. I've double checked the keyname and it is a valid name. I also just tried a really simple key name, but the data wasn't modified either, so I think there's something else going on but I have no idea what. If anything I'm thinking it might be that I have the wrong effect selected? But that really should be the right one...
BadIdeasBureau
Honestly not sure - try throwing in a console.log(effect) to check it's the right one?
Ethck
Ethck3y ago
I did. Here's the output (afaik it's the right one???).
No description
BadIdeasBureau
OH! effect.update({"changes[1].value": (the "update" applies to "data", so you skip the first "data") I think you still want the "data" in armor of agathys, since that's system defined data (so it's actually item.data.data.uses.value)
Ethck
Ethck3y ago
That would make sense, but it still doesn't work.
No description
Ethck
Ethck3y ago
Are you allowed to use array indexing in the key field? I'm starting to think it might be because of this? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names Okay, it's definitely because of that If I change the key to "label" then it immediately works I'm going to throw a general question over into #development