本帖最后由 pkeasygod 于 2024-10-25 16:49 编辑
1.有使用头像可以用AutoNamePopup.js
设定后读取头像自动输入名称
2.读取文本(name:x)输入名称
(() => { const parameters = PluginManager.parameters(document.currentScript.src.split('/').pop().replace(/\.js$/, "")); const templateBase = parameters['template'] || "%1"; const exclusionList = JSON.parse(parameters['exclusionList'] || "[]").map(cc => new RegExp(cc, "i")); const template = parameters['startNewLine'] === "true" ? `${templateBase}\n` : templateBase; const _Game_Message_prototype_add = Game_Message.prototype.add; Game_Message.prototype.add = function(text) { text = text.replace(/\(name:(\d+)\)/gi, (match, p1) => { return String($gameVariables.value(Number(p1))); }); text = Window_Message.prototype.convertEscapeCharacters.call(this, text); _Game_Message_prototype_add.call(this, text); }; const _Game_Interpreter_command101 = Game_Interpreter.prototype.command101; Game_Interpreter.prototype.command101 = function() { const params = this.currentCommand().parameters; const nextParams = this._list[this._index + 1]?.parameters; if (nextParams) { const extractedName = nextParams[0].match(/\(name:(.+?)\)/)?.[1] || ""; if (extractedName) { params[4] = template.replace('%1', extractedName); nextParams[0] = nextParams[0].replace(/\(name:.+?\)/gi, "").trim(); } } return _Game_Interpreter_command101.call(this, params); }; const _Window_Base_convertEscapeCharacters = Window_Base.prototype.convertEscapeCharacters; Window_Base.prototype.convertEscapeCharacters = function(text) { text = _Window_Base_convertEscapeCharacters.call(this, text).replace(/\(name:(.+?)\)/gi, (_, p1) => { return p1; }).trim(); return text; }; })();
(() => {
const parameters = PluginManager.parameters(document.currentScript.src.split('/').pop().replace(/\.js$/, ""));
const templateBase = parameters['template'] || "%1";
const exclusionList = JSON.parse(parameters['exclusionList'] || "[]").map(cc => new RegExp(cc, "i"));
const template = parameters['startNewLine'] === "true" ? `${templateBase}\n` : templateBase;
const _Game_Message_prototype_add = Game_Message.prototype.add;
Game_Message.prototype.add = function(text) {
text = text.replace(/\(name:(\d+)\)/gi, (match, p1) => {
return String($gameVariables.value(Number(p1)));
});
text = Window_Message.prototype.convertEscapeCharacters.call(this, text);
_Game_Message_prototype_add.call(this, text);
};
const _Game_Interpreter_command101 = Game_Interpreter.prototype.command101;
Game_Interpreter.prototype.command101 = function() {
const params = this.currentCommand().parameters;
const nextParams = this._list[this._index + 1]?.parameters;
if (nextParams) {
const extractedName = nextParams[0].match(/\(name:(.+?)\)/)?.[1] || "";
if (extractedName) {
params[4] = template.replace('%1', extractedName);
nextParams[0] = nextParams[0].replace(/\(name:.+?\)/gi, "").trim();
}
}
return _Game_Interpreter_command101.call(this, params);
};
const _Window_Base_convertEscapeCharacters = Window_Base.prototype.convertEscapeCharacters;
Window_Base.prototype.convertEscapeCharacters = function(text) {
text = _Window_Base_convertEscapeCharacters.call(this, text).replace(/\(name:(.+?)\)/gi, (_, p1) => {
return p1;
}).trim();
return text;
};
})();
|