• 📚 Admin Project Update: I've added a major feature to PictureBooks.io called Avatar Studio! You can now upload photos to instantly turn your kids (and pets! 🐶) into illustrated characters that star in their own stories. Give it a try and let me know what you think!

configuring mod Options with a dedicated Mods tab

Update 1.3.0 changed the Options screen in a way that is breaking this code. to work around the problem, you can add this block to your -options.js script before calling Options.addInitCallback for the first time. i've also sent this to the Firaxis community team to let the devs know that this is a pain point for modders.

JavaScript:
// fix Options initialization
Options.addInitCallback = function(callback) {
    if (this.optionsReInitCallbacks.length && !this.optionsInitCallbacks.length) {
        throw new Error("Options already initialized, cannot add init callback");
    }
    this.optionsInitCallbacks.push(callback);
    this.optionsReInitCallbacks.push(callback);
}
 
Update 1.3.0 changed the Options screen in a way that is breaking this code. to work around the problem, you can add this block to your -options.js script before calling Options.addInitCallback for the first time. i've also sent this to the Firaxis community team to let the devs know that this is a pain point for modders.

JavaScript:
// fix Options initialization
Options.addInitCallback = function(callback) {
    if (this.optionsReInitCallbacks.length && !this.optionsInitCallbacks.length) {
        throw new Error("Options already initialized, cannot add init callback");
    }
    this.optionsInitCallbacks.push(callback);
    this.optionsReInitCallbacks.push(callback);
}
this bug was fixed in Update 1.3.1 so the workaround is no longer necessary. i recommend removing it from your code, because it's risky for multiple mods to patch the same vanilla code.
 
Back
Top Bottom