I'm trying to use SRD's File Reading/Writing system, and it works just fine in playtesting, but when I test the deployed version, the game isn't able to create the file.
Here's the code that I'm using in my game to create the file.
This script is supposed to create a file in the "/data/key" folder of the game, and write some text into it.
However, while I have this running perfectly in playtesting, it doesn't work during a deployed game: no file gets created, and even if the file already exists, nothing gets written inside it.
Any suggestions? Any fixes I need to do with the code?
If you want me to provide a demo, feel free to ask, and I'll upload it when I'm able to.
Here's the code that I'm using in my game to create the file.
Code:
//Write Text File
var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/data/key/');
if (path.match(/^\/([A-Z]\:)/)) {
path = path.slice(1);
}
path = decodeURIComponent(path) + "MysticKey.wlgp";
var fs = require('fs');
fs.writeFile(path, "long_text_string_here", function(err) {
if(err) {
return console.log(err);
}
});
This script is supposed to create a file in the "/data/key" folder of the game, and write some text into it.
However, while I have this running perfectly in playtesting, it doesn't work during a deployed game: no file gets created, and even if the file already exists, nothing gets written inside it.
Any suggestions? Any fixes I need to do with the code?
If you want me to provide a demo, feel free to ask, and I'll upload it when I'm able to.