El Gobbo
El Gobbo
Problems updating to v12
Hi guys, I am still working on the same system, using v11 (as that is the version I have installed due to some other games I am running) and starting from the boilerplate system builder using Data Models. My goal however has always been to get this system running on v12, so today I installed all my coding software on another machine along with the latest version of foundry and transferred over my project, only to find that I cannot even open it - base foundry does not even load. On examination of the console, I found the following error: Uncaught (in promise) Error: A DataSchema must be an object with string keys and DataField values. After fiddling around for a while, I found out the following: first, if I remove any of the files containing my Data Models, I can load base foundry, but none of the other Data Models load either; second, if I remove the line in the _module file that exports any of my Data Models, foundry also fails to load and I get the following error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'LOCALIZATION_PREFIXES') Are these errors linked, what am I missing, and what can I do to get my module running in foundry v12?
5 replies
Array keeps resetting
Hi, I am very new to system development/programming and trying to put together a system for an rpg that does not currently have an implementation by starting from boilerplate. Due to the requirements of games I currently run on foundry, I am using version 11+. I am trying to store player-inputted values in an arrayField of variable length determined by player level, attached to the player characters datamodel. The idea is that players can only store a limited number of values, before they need to replace one. However, every time the Document updates, the array resets to empty. How can I get the array to persist? What am I missing? The datamodel declaring the array
cs
static defineSchema() {
const { SchemaField, NumberField, StringField, ArrayField, HTMLField } = foundry.data.fields;
const requiredInteger = { required: true, nullable: false, integer: true };
const schema = super.defineSchema();

schema.foci = new SchemaField({
value: new NumberField({ ...requiredInteger, initial: 1 }),
slots: new ArrayField(new StringField()),
});
cs
static defineSchema() {
const { SchemaField, NumberField, StringField, ArrayField, HTMLField } = foundry.data.fields;
const requiredInteger = { required: true, nullable: false, integer: true };
const schema = super.defineSchema();

schema.foci = new SchemaField({
value: new NumberField({ ...requiredInteger, initial: 1 }),
slots: new ArrayField(new StringField()),
});
The loop pushing new values onto the array
cs
prepareDerivedData() {
let foci = this.foci.value;
let currentSlots = this.foci.slots.length;
if (currentSlots < foci){
for (let i = currentSlots; i < foci; i++){
this.foci.slots.push(i);
}
};
cs
prepareDerivedData() {
let foci = this.foci.value;
let currentSlots = this.foci.slots.length;
if (currentSlots < foci){
for (let i = currentSlots; i < foci; i++){
this.foci.slots.push(i);
}
};
I have tried removing the loop, but the results seem to be the same. Sorry if this is a super basic question, but I've been stuck on this for hours
4 replies