//=============================================================================
// filePath.js
//=============================================================================
/*:
* @plugindesc tests behaviour when writing a file
* @author RSJG
*
* @help Yes please.
*/
{
fs = require("fs");
function getPath(unformattedPath) {
let path = "/" + unformattedPath + "/";
//reg-ex magic here
console.log("file path is: " + path); //"file path is: /testpath/""
return path;
}
function writeFile(path, name, data){
let wPath = (path === "") ? "" : getPath(path);
fs.writeFileSync(wPath + name, data);
}
const Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === "writetest") {
writeFile("testpath","testfile2.txt","Hello Path + File!");
}
if (command.toLowerCase() === "writetestnp") {
writeFile("","testfile1.txt","Hello File!");
}
}
};