Aaron
Aaron
Extend ActiveEffect.changes
Not sure I understand your "empty" ArrayField comment. I found the {required: false}, which allows for spare arrays. Is there some sort of {empty: ?} option for ArrayFields that removes the spares property?
88 replies
Extend ActiveEffect.changes
Is my use of getData to merge not ideal?
88 replies
Extend ActiveEffect.changes
There are a couple of data prep functions, which one should I look at?
88 replies
Extend ActiveEffect.changes
I sorta need a 1-1 match so I can do some backend calculations & change.value fading (custom system rules). Given there is no unique key, I'm left with an index to do the matching.
88 replies
Extend ActiveEffect.changes
async getData() {
const context = await super.getData();
for (let i = 0; i < context.data.changes.length; i++) {
context.data.changes[i] = { ...context.data.changes[i], ...context.data.system.changes?.[i] };
}
async getData() {
const context = await super.getData();
for (let i = 0; i < context.data.changes.length; i++) {
context.data.changes[i] = { ...context.data.changes[i], ...context.data.system.changes?.[i] };
}
88 replies
Extend ActiveEffect.changes
No description
88 replies
Extend ActiveEffect.changes
I supposed I can perform a filter during the merge...
88 replies
Extend ActiveEffect.changes
Yuck, when I make the ArrayField not required the merge of changes and system.changes no longer is 1-1 and it makes a mess of things.
export class HeroSystem6eActorActiveEffectsSystemData extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
changes: new fields.ArrayField(
new fields.SchemaField(
{
seconds: new fields.NumberField({ integer: true }),
activePoints: new fields.NumberField({ integer: false }),
source: new fields.StringField(),
startTime: new fields.NumberField({ integer: true }),
},
{ required: false },
),
),
};
}
}
export class HeroSystem6eActorActiveEffectsSystemData extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
changes: new fields.ArrayField(
new fields.SchemaField(
{
seconds: new fields.NumberField({ integer: true }),
activePoints: new fields.NumberField({ integer: false }),
source: new fields.StringField(),
startTime: new fields.NumberField({ integer: true }),
},
{ required: false },
),
),
};
}
}
88 replies
Extend ActiveEffect.changes
Like I said I have it working. I'm willing to try more suggestions to make it work better or more inline with foundry/dev recommendations.
88 replies
Extend ActiveEffect.changes
BTW: I'm learning alot in this thread. Thanks for your time!
88 replies
Extend ActiveEffect.changes
If I delete the last change and the array indexes 1-X are sequential, it coerces into an array just fine.
88 replies
Extend ActiveEffect.changes
the coercion into an array bypasses this issue.
88 replies
Extend ActiveEffect.changes
No description
88 replies
Extend ActiveEffect.changes
taking out my "custom" fix and see if it coerces like you said is should.
88 replies
Extend ActiveEffect.changes
No description
88 replies
Extend ActiveEffect.changes
No description
88 replies