Writing JSON Files

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
268
First Language
English
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.
 

Quxios

Veteran
Veteran
Joined
Jan 8, 2014
Messages
1,055
Reaction score
785
First Language
English
Primarily Uses
RMMV
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);
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
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 :)
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
268
First Language
English
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. 
 
Last edited by a moderator:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
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 :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top