You have also a way with
nwJS NODE, its easy but it not compatible with Android.
Here the two way you can do, maybe more ?...
XMLHTTPRequest:
PHP:
DataManager.loadDataFile = function(name, src) { // testter compatible android
var xhr = new XMLHttpRequest();
var url = 'data/' + src;
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function() {
if (xhr.status < 400) {
window[name] = JSON.parse(xhr.responseText);
DataManager.onLoad(window[name]);
}
};
xhr.onerror = this._mapLoader || function() {
DataManager._errorUrl = DataManager._errorUrl || url;
};
window[name] = null;
xhr.send();
Node: (
it a copy paste from my source , but you need more study with consol.log variable, its more powerfull way, but not work on Android)
PHP:
if(Utils.isNwjs()){ // if pc or mac linux TODO: ANDROID + loader
var path = require('path'),
gameDir = path.dirname(process.mainModule.filename),
fs = require('fs');
var valid_JSON = {};
for (objName in this._aniObj) {
if (typeof this._aniObj[objName] !== "object") { continue; }; // jumper valide name 'object'
valid_JSON[objName] = [];
for (var i = 0, len = this._aniObj[objName].json.length; i < len; i++) {
var dirFile = this._aniObj[objName].json[i];
if (fs.existsSync(gameDir + '/' + dirFile + '.json')) {
valid_JSON[objName].push(dirFile + '.json');
continue;
};
for (var num = 0;; num++) {
if (fs.existsSync(gameDir + '/' + dirFile + '-' + num + '.json')) {
valid_JSON[objName].push(dirFile + '-' + num + '.json');
} else { break; };
};
};
};
for (objName in valid_JSON) {
Object.defineProperty(this._aniObj[objName], 'valid_JSON', { enumerable: false, configurable: false, value: valid_JSON[objName] });
};
here a example for get your machine id in windows with open file in a buffer.
Easy for open a file , and read context buffer, this for made a custom keyGen or function evaluation from your saves DATA in JSON or another files extentions.
PHP:
var fs = require('fs');
var path = process.cwd();
var buffer = fs.readFileSync('C:\\Windows\\INF\\machine.inf');
console.log(buffer.toString());
after you can use a
regex if you need read string in the file.
More info:
https://forums.rpgmakerweb.com/index.php?threads/node-js-machineid-solved.81127/#post-753862
In you specific case, you can read all save file and proprety from JSON as string, and use
eval("string").
from the regex