Module:GameData/doc: Difference between revisions

Update code: Amend namespace data
(Update code)
(Update code: Amend namespace data)
Line 18: Line 18:
         this.packData = {};
         this.packData = {};
         this.gameData = {};
         this.gameData = {};
        this.gameData.namespaces = {};
         this.dataPropFilters = {
         this.dataPropFilters = {
             // Specifies rules for properties of entities (items, monsters, etc.) which
             // Specifies rules for properties of entities (items, monsters, etc.) which
Line 303: Line 302:
             throw new Error(`Couldn't find data for package ${ namespace }`);
             throw new Error(`Couldn't find data for package ${ namespace }`);
         }
         }
         // Add namespace entry to game data
         // Add data within the game but outside of data packs
        this.gameData.namespaces[namespace] = this.namespaces[namespace];
         this.registerNonPackData();
         this.registerNonPackData();
         // Consolidate data
         // Consolidate data
Line 452: Line 450:
     registerNonPackData() {
     registerNonPackData() {
         // Some data resides outside of packages. Add any such data to this.gameData within this function
         // Some data resides outside of packages. Add any such data to this.gameData within this function
        if (this.gameData.namespaces === undefined) {
            const nsData = [];
            game.registeredNamespaces.forEach((ns) => nsData.push(ns));
            this.gameData.namespaces = nsData;
        }
         if (this.gameData.combatTriangles === undefined) {
         if (this.gameData.combatTriangles === undefined) {
             const ctData = [];
             const ctData = [];