Tutorial for a New JSON file?

Linard

Veteran
Veteran
Joined
Jun 29, 2016
Messages
202
Reaction score
18
First Language
Filipino
Primarily Uses
RMMV
Hello guys, Is there any tutorial on how saving and load process are works? because i want to create a new JSON file and i don't know what are the functions on the DataManager should i allias or use to manage the Update and Getting a data from a JSON file. I tried to read some scripts of others like the Quest scripts and still can't understand what they do haha! Sorry I'm a newbie in scripting. Thanks in advance :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,714
First Language
English
Primarily Uses
RMMV
What kind of file are you adding - something similar to the $data... files?


What I normally do is just look through DataManager, and wherever the $data... files are used, I will add something similar in my plugin.


Let's go through it ... we'll use a new variable called $dataMyData for the example (all of this is within your own plugin).


var $dataActors = null;


just initializing it to contain nothing.  This probably doesn't need to be done, but for completeness, we'll do it:


var $dataMyData = null;





Code:
DataManager._databaseFiles = [
    { name: '$dataActors',       src: 'Actors.json'       },
...

This is where it lists all the files that need to be loaded on launching the game, and what global variable (array) they're going to be put into.  We don't want to redefine it (as that would remove all the default ones), we just want to add to it:


DataManager._databaseFiles.push({ name: '$dataMyData', src: 'MyData.json' });






If that's all you want to do - load it when the game is launched, that's all you need to add, apart from the rest of your plugin to actually use it.  If you want to do more stuff, like setting things up after the data is loaded, you can do that in the DataManager.onLoad function:


var _DataManager_onLoad = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad.call(this, object);
if (object === $dataMyData) {
// do other stuff here
}
};






However, if you want to create a new class, like $gameActors, $gameSystem, etc that get saved with the player's save file, that's a completely different process.
 
Last edited by a moderator:

Linard

Veteran
Veteran
Joined
Jun 29, 2016
Messages
202
Reaction score
18
First Language
Filipino
Primarily Uses
RMMV
Thanks :)  for the quick response.


Yes! something similar to the $data... files.
 


Now, I got how to load the JSON  files. Thank you  :)


That creating a new class like $game.. is too difficult to understand.


And extracting the contents to a particular class (ex: $gameMyclass) is to confusing hehehe.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,714
First Language
English
Primarily Uses
RMMV
It's not necessarily difficult - it's actually pretty easy.  You just do it differently, that's all.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

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,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top