$._dumpEvents = function(event_id, separator, text_filename) {
const fs = require('fs');
const CMD_LIST = ["Show Text","Show Choices","Input Number","Select Item","Show Scrolling Text","Control Switches","Control Variables","Control Self Switch","Control Timer","Conditional Branch","Loop","Break Loop","Exit Event Processing","Common Event","Label","Jump to Label","Comment","Change Gold","Change Items","Change Weapons","Change Armors","Change Party Member","Change HP","Change MP","Change TP","Change State","Recover All","Change EXP","Change Level","Change Parameter","Change Skill","Change Equipment","Change Name","Change Class","Change Nickname","Change Profile","Transfer Player","Set Vehicle Location","Set Event Location","Scroll Map","Set Movement Route","Get on/off Vehicle","Change Transparency","Change Player Followers","Gather Followers","Show Animation","Show Balloon Icon","Erase Event","Show Picture","Move Picture","Rotate Picture","Tint Picture","Erase Picture","Wait","Fadeout Screen","Fadein Screen","Tint Screen","Flash Screen","Shake Screen","Set Weather Effect","Play BGM","Fadeout BGM","Save BGM","Replay BGM","Play BGS","Fadeout BGS","Play ME","Play SE","Stop SE","Play Movie","Battle Processing","Shop Processing","Name Input Processing","Open Menu Screen","Open Save Screen","Gave Over","Return to Title Screen","Change Battle BGM","Change Victory ME","Change Defeat ME","Change Vehicle BGM","Change Save Access","Change Menu Access","Change Encounter","Change Formation Access","Change Window Color","Change Actor Images","Change Vehicle Image","Change Map Name Display","Change Tileset","Change Battle Back","Change Parallax","Get Location Info","Change Enemy HP","Change Enemy MP","Change Enemy TP","Change Enemy State","Enemy Recover All","Enemy Appear","Enemy Transform","Show Battle Animation","Force Action","Abort Battle","Script","Plugin Command"]
var event_object_list = $gameMap.event(event_id).list();
var event_list_array = Object.keys(event_object_list).map(function(key) {
return [Number(key), event_object_list[key]];
});
var new_array = [];
var cmd_list_count = 0;
for (var i = 0; i < event_list_array.length; i++) {
if (event_list_array[i][1].parameters[0] === separator) {
new_array.push(CMD_LIST[cmd_list_count] + ":");
cmd_list_count++;
} else {
new_array.push(event_list_array[i][1].code + "\n");
};
};
fs.writeFile(text_filename, new_array.join('\n'), 'utf8', function (err) {
if (err) {
return console.log(err);
} console.log("The file was saved!");
});
};