本帖最后由 pkeasygod 于 2024-11-28 09:34 编辑
1.有使用头像可以用AutoNamePopup.js
设定后读取头像自动输入名称
2.读取文本(name:x)输入名称
(() => { const parameters = PluginManager.parameters(document.currentScript.src.split('/').pop().replace(/\.js$/, "")); const templateBase = parameters['template'] || "%1"; 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, (_, p1) => 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?.[0]) { 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) { return _Window_Base_convertEscapeCharacters.call(this, text) .replace(/\(name:(.+?)\)/gi, (_, p1) => p1) .trim(); }; })();
(() => {
const parameters = PluginManager.parameters(document.currentScript.src.split('/').pop().replace(/\.js$/, ""));
const templateBase = parameters['template'] || "%1";
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, (_, p1) =>
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?.[0]) {
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) {
return _Window_Base_convertEscapeCharacters.call(this, text)
.replace(/\(name:(.+?)\)/gi, (_, p1) => p1)
.trim();
};
})();
|