When the game is exported to Android, my plugin just doesn't work at all. When the command is activated, nothing happens. I don't know, maybe there is a problem with the permissions, maybe the maker just doesn't digest the "click", I don't know. Help, who knows what to do with it
here's the plugin I used as a base:
forums.rpgmakerweb.com
also I am using jsZIP library
here's the plugin I used as a base:
[HTML5] Export/Import save data
Hi guys, i'm making my own game with RPG Maker MV but i have an question. Is that a plugin exist to export and Import the savedata in a file ? Exemple: i have became the game and i save my progression but i want to continue the game in other computer or smartphone. Because if my...
forums.rpgmakerweb.com
also I am using jsZIP library
Code:
(function($, undefined) {
"use strict";
$.SAVE = {
export: function() {
const zip = new JSZip();
for (let i = 1; i < 70; i++) {
var info = DataManager.loadSavefileInfo(i),
data = StorageManager.load(i);
if (info || data) {
var filename = `saveFile${i}.json`;
var encoded = LZString.compressToBase64(JsonEx.stringify({ info: info, data: data }));
zip.file(filename, encoded);
}
}
zip.generateAsync({type:"blob"}).then(function(encoded) {
var elementd = document.createElement('a');
elementd.href = URL.createObjectURL(encoded);
elementd.setAttribute('download', "save.zip");
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
elementd.dispatchEvent(event);
} else { elementd.click(); }
});
},
import: function() {
var input = document.createElement('input');
input.type = 'file';
input.accept = '.zip';
input.style.display = 'none';
input.onchange = function(e) {
var file = e.target.files[0];
if (!file.name.endsWith('.zip')) {
window.alert('Invalid file type. Please select a .zip file.');
return;
}
var reader = new FileReader();
reader.onload = function(event) {
var zip = new JSZip();
var fs = require("fs");
fs.readFile(file.path, function(err, data) {
zip.loadAsync(data).then(function(zipContent) {
var globalInfo = DataManager.loadGlobalInfo();
var promises = [];
for (let i = 1; i <= 70; i++) {
let fileName = `saveFile${i}.json`;
if (zipContent.file(fileName)) {
promises.push(
zipContent.file(fileName).async('string').then(function(fileContent) {
const data = JsonEx.parse(LZString.decompressFromBase64(fileContent));
globalInfo[i] = data.info;
DataManager.saveGlobalInfo(globalInfo);
StorageManager.save(i, data.data);
})
);
}
}
Promise.all(promises).then(function() {
window.alert('Import successful for all valid save files. Please restart the game for changes to take effect.');
}).catch(function(error) {
window.alert('An error occurred while importing: ' + error.message);
});
}).catch(function(error) {
console.log(error);
});});
};
reader.readAsArrayBuffer(file);
};
document.body.appendChild(input);
input.click();
document.body.removeChild(input);
}
};
})(this.sythG || (this.sythG = {}));