Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
How to do I set the default value for a member of the type BOOLEAN_FIELD in a derived class from foundry.abstract.DocumentData in foundry vvt?

Is there a hook / overwriteable function, when a placeable foundry vvt object was succesfully added to the scene and is ready to be used?

calling

const myown_data = { give_me_icecream: true }
canvas.scene.updateEmbeddedDocuments('ContainerName',[{ _id: this.data._id, ...myown_data }])

in

 _onCreate

complains that the data could not be written / saved when I create the object. But when I reload the scene the data is written to all objects of the type without a problem. I would like to just to set some default values for a BOOLEAN_FIELD or any other DocumentField in a foundry.abstract.DocumentData Class, which should be used only when the object is created for the first time.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution is to overwrite the _initialize () function of DocumentData (in the module folder it is name something like ModuleNameData.js).

export class MyOwnClassData extends foundry.abstract.DocumentData {
  static defineSchema () 
{ 
      _id: fields.DOCUMENT_ID,
      scene: {
        ...fields.DOCUMENT_ID,
        required: false,
        nullable: true
      },
      my_own_member: fields.BOOLEAN_FIELD
}
  _initialize () {
    super._initialize()
    this.my_own_member = true
  } 
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!