|
导出事件及公共事件中的文章、选择项文本
脚本:exportTexts.js
- /*:
- * @target MZ
- * @plugindesc 导出显示文章和选择项的文本
- *
- * 更多插件请访问 www.hknmtt.com
- * @author 烁灵
- *
- * @help exportTexts.js
- * 启用插件后,进入标题界面,会在游戏文件夹内生成包含所有文本的 exportText.txt
- *
- */
- (function() {
- var _index = 1;
- const fs = require("fs");
-
- sl_initialize = Scene_Title.prototype.initialize;
- Scene_Title.prototype.initialize = function() {
- sl_initialize.call(this);
- this.loadMap($dataMapInfos[_index].id);
- this._exportData = [];
- };
-
- Scene_Title.prototype.loadMap = function(id) {
- const src = "Map%1.json".format(id.padZero(3));
- const xhr = new XMLHttpRequest();
- const url = "data/" + src;
- $dataMap = null;
- xhr.open("GET", url);
- xhr.overrideMimeType("application/json");
- xhr.onload = () => this.onXhrLoad(xhr, name, src, url);
- xhr.send();
- };
- Scene_Title.prototype.onXhrLoad = function(xhr, name, src, url) {
- if (xhr.status < 400) {
- $dataMap = JSON.parse(xhr.responseText);
- this.onMapLoaded();
- }
- };
- Scene_Title.prototype.onMapLoaded = function() {
- this.process_mapInfo();
- _index += 1;
- if ($dataMapInfos[_index]) {
- this.loadMap($dataMapInfos[_index].id);
- } else {
- $dataCommonEvents.forEach(eventPage => {
- if (eventPage) {
- this.writePageText(eventPage);
- }
- })
- fs.writeFileSync("exportText.txt", this._exportData.join("\r\n"));
- }
- }
- Scene_Title.prototype.writePageText = function(page) {
- page.list.forEach(command => {
- console.log(command)
- if (command.code == 401) {
- // 显示文章
- this.write(command.parameters[0]);
- }
- if (command.code == 102) {
- // 选项
- command.parameters[0].forEach(param => {
- this.write(param);
- });
- }
- })
- }
- Scene_Title.prototype.write = function(str) {
- console.log("write " + str);
- this._exportData.push(str);
- }
- Scene_Title.prototype.process_mapInfo = function() {
- console.log($dataMap);
- $dataMap.events.forEach(event => {
- if (event) {
- event.pages.forEach(page => {
- if (page) {
- this.writePageText(page);
- }
- });
- }
- })
- };
- })();
复制代码
|
|