Writing JSON Files

Ok so in order to save generated items and actors onto the game I use the following:

 

var data = JSON.stringify($dataItems); var fs = require('fs'); var dirPath = function(){ var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/data/'); if (path.match(/^\/([A-Z]\🙂/)) { path = path.slice(1); } return decodeURIComponent(path); }; var filePath = dirPath() + 'Items.json'; fs.writeFileSync(filePath, data);The problem is: JSON for actors and Items is shared through all save files. For a pokemon type game this is not a problem since they typically have only one save file.

Also this writes onto the data used for making the game so it wont show up in the database.

I tried using: http://www.rpgmakermv.co/threads/doublex-rmmv-dynamic-data.661/

But it doesn't work properly and gives me errors.

Does anyone else know of way besides writing to the JSON files?

I suppose I could hook into Game_System but I am not sure on how much space this would take up.
Well it looks like you want the data to be different on every load. In that case I would say to store the object into Game_System. And I don't think you need to worry about the space, it'll just make the save file slightly bigger depending on your object size. But since it's all text it'll still be very small.

Other then that, I write my jsons pretty much the same way except I save it in it's own file instead of an existing JSON.

Code:
var newFile = JSON.stringify(someobject, null, 2);var fs = require('fs');// get filepath and stufffs.writeFileSync(filePath + "/nameOfJSONFile.JSON", newFile);
You should store this kind of information inside the savefile, because otherwise it will affect all games. You can do this either manually and hook into the loading methods of DataManager or use this plugin to store the whole $dataItems inside inside the save: http://forums.rpgmakerweb.com/index.php?/topic/48589-doublex-rmmv-dynamic-data
Ok so in order to save generated items and actors onto the game I use the following:

 

var data = JSON.stringify($dataItems); var fs = require('fs'); var dirPath = function(){ var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/data/'); if (path.match(/^\/([A-Z]\🙂/)) { path = path.slice(1); } return decodeURIComponent(path); }; var filePath = dirPath() + 'Items.json'; fs.writeFileSync(filePath, data);The problem is: JSON for actors and Items is shared through all save files. For a pokemon type game this is not a problem since they typically have only one save file.

Also this writes onto the data used for making the game so it wont show up in the database.

I tried using: http://www.rpgmakermv.co/threads/doublex-rmmv-dynamic-data.661/

But it doesn't work properly and gives me errors.

Does anyone else know of way besides writing to the JSON files?

I suppose I could hook into Game_System but I am not sure on how much space this would take up.
I'm interested in the error logs you received 🙂
Error is something like, cannot find window tone of null.

I couldn't really figure out what was giving me the error.

It is with the title screen part I believe. 

Also it doesn't let me open up a save file, each one gives me the buzzer sound. Quite strange.

What I have done in the mean time is just add the actors back onto the $dataActors after the database is loaded.

Your script does a similar concept but I can't figure out what is wrong. 
Try this snippet:

DataManager.saveGame = function(savefileId) { return this.saveGameWithoutRescue(savefileId);};DataManager.loadGame = function(savefileId) { return this.loadGameWithoutRescue(savefileId);};And now error messages should be shown whenever the saving/loading fails 🙂

Original thread: https://forums.rpgmakerweb.com/threads/writing-json-files.51614/