MV Read/Write Text-Files on Mobile Devices

Hi there,

I searched the whole morning today, but either I am to stupid to find the correct search words or there is no solution for this. 🙄

I want to write/read a text file on iOS in my MV Game.

I found a code snippet wich works on the Mac

Code:
var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/data/');
if (path.match(/^\/([A-Z]\:)/)) {
    path = path.slice(1);
}
path = decodeURIComponent(path) + "save.txt";
var fs = require('fs');
fs.writeFile(path, "Game Complete", function(err) {
    if(err) {
        return console.log(err);
    }
});

But I get an error if I want to use it on my iPhone.

It says
ReferenceError
Can't find variable:require

Can someone help me with this?

Thank you and best regards
Andreas
This code uses the file system module from node.js. Browsers don't support node.js methods like require so it won't work on mobile.
I haven't tested it but there's this thing called browserify that can apparently run require in browsers.
Thank you, I try to look at this.

I have found an alternative solution if you run on Mac OS or iOS, don't have tested on PC and Android yet.

Event 1
var storage = window.localStorage;
storage.setItem('test','Some test text');

Event 2
var storage = window.localStorage;
$gameVariables.setValue(1, storage.getItem('test'));

Original thread: https://forums.rpgmakerweb.com/threads/read-write-text-files-on-mobile-devices.129810/