Hello,
Sorry non native speaker.
I`ve come to you for help. i`m working on a RMMZ project that is intended to help young adults choose an educational path. Several jobs are described and then there are some tests in math, logic, grammar and stuff.
Depending on the results the YA will be further counseled.
The test are working, the results are saved in variables 1 to 5, in Nr. 6 the name of the testee is saved.
The thing is... I want to export the values of the variables to preferable excel but even txt would be fine.
SInce I don`t know any programmer or javascript myself I asked Chat GPT 4 for help and it created this plugin fpr me:
/*:
* @target MZ
* @plugindesc Exports variables 1 to 6 to a text file
* @command ExportVariables
* @text Export Variables
* @desc Exports variables 1 to 6 to a 'variables.txt' file in the game directory.
*/
(() => {
const pluginName = "ExportVariablesToTxt";
PluginManager.registerCommand(pluginName, "ExportVariables", args => {
const fs = require('fs');
const path = require('path');
let variablesData = "";
// Gather variables 1 to 6
for (let i = 1; i <= 6; i++) {
variablesData += `Variable ${i}: ${$gameVariables.value(i)}\n`;
}
// Define the file path
const filePath = path.join(path.dirname(process.mainModule.filename), 'variables.txt');
// Write the data to the text file
fs.writeFileSync(filePath, variablesData);
console.log('Variables 1 to 6 exported to ' + filePath);
});
})();
I can run the Plug-In command but neither in Test Mode nor in Game Mode a file is created. It`s getting kind of frustrating.
Is it that I don`t have entered a real directory to save? Or where is the coding error?
Any help would be really appreciated...
Sorry non native speaker.
I`ve come to you for help. i`m working on a RMMZ project that is intended to help young adults choose an educational path. Several jobs are described and then there are some tests in math, logic, grammar and stuff.
Depending on the results the YA will be further counseled.
The test are working, the results are saved in variables 1 to 5, in Nr. 6 the name of the testee is saved.
The thing is... I want to export the values of the variables to preferable excel but even txt would be fine.
SInce I don`t know any programmer or javascript myself I asked Chat GPT 4 for help and it created this plugin fpr me:
/*:
* @target MZ
* @plugindesc Exports variables 1 to 6 to a text file
* @command ExportVariables
* @text Export Variables
* @desc Exports variables 1 to 6 to a 'variables.txt' file in the game directory.
*/
(() => {
const pluginName = "ExportVariablesToTxt";
PluginManager.registerCommand(pluginName, "ExportVariables", args => {
const fs = require('fs');
const path = require('path');
let variablesData = "";
// Gather variables 1 to 6
for (let i = 1; i <= 6; i++) {
variablesData += `Variable ${i}: ${$gameVariables.value(i)}\n`;
}
// Define the file path
const filePath = path.join(path.dirname(process.mainModule.filename), 'variables.txt');
// Write the data to the text file
fs.writeFileSync(filePath, variablesData);
console.log('Variables 1 to 6 exported to ' + filePath);
});
})();
I can run the Plug-In command but neither in Test Mode nor in Game Mode a file is created. It`s getting kind of frustrating.
Is it that I don`t have entered a real directory to save? Or where is the coding error?
Any help would be really appreciated...