RPG Maker Forums

I'm writing a plugin for a little game I am developing that will need to load an additional JSON file into a variable used by the plugin itself.

Code:
(function () {
    function MyManager() {
        throw new Error("This is a static class");
    }
   
    MyManager._mydata = null;
  
    DataManager._databaseFiles.push(
       { name: 'MyManager._mydata',       src: 'custom.json'       }
    )   
   
    [...]
})();
Notes:
- custom.json exists and it is placed in "data/" folder together with the default JSon files.
- custom.json is a valid json file that it was generated by a python script I wrote

----

Well... the problem is that MyManager._mydata is actually null and did not load the json data. I'm reading deeper the core JS files and I tried to understand how DataManager.loadDataFile and DataManager.onLoad but I can't understand how (and where) the strings like "$dataActors'' are able to direct the code to actually fill the (global) variable with that name.

Side note: the data contained in custom.json is not an Array of values, but a dictionary that currently contains two keys and their values.

Here also the current version of custom.json:

{"alfa": {"1": {"stats": {"1,1": 1000}, "actors": {"1,1": [17, 18, 19, 20]}}, "2": {"stats": {"1,2": 200, "1,1": 800}, "actors": {"1,1": [17, 18, 19, 20]}}, "3": {"stats": {"1,2": 450, "1,1": 550}, "actors": {"1,1": [17, 18, 19, 20]}}, "4": {"stats": {"1,2": 1000}, "actors": {}}, "5": {"stats": {"1,2": 400, "1,3": 100, "1,1": 500}, "actors": {"1,1": [17, 18, 19, 20]}}, "6": {"stats": {"1,3": 1000}, "actors": {}}, "7": {"stats": {"1,3": 950, "1,4": 50}, "actors": {}}, "8": {"stats": {"1,2": 220, "1,3": 430, "1,4": 350}, "actors": {}}, "9": {"stats": {"1,2": 50, "1,1": 950}, "actors": {"1,1": [17, 18, 19, 20]}}, "10": {"stats": {"1,5": 30, "1,3": 700, "1,4": 270}, "actors": {}}}, "beta": {"0": {"stats": {"1,2": 450, "1,3": 50, "1,1": 500}, "actors": {"1,1": [17, 18, 19, 20]}}, "1": {"stats": {"1,3": 15.0, "1,4": 265.0}, "actors": {}}}}

The two main keys are "alfa" and "beta". Each key contains "index sub-key". Each of index subjey have a "stats" and "actors" dictorinaries.

So my doubt is: how can I load the JSON data in MyManager._mydata

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top