35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
/*:
|
|
* @target MZ
|
|
* @plugindesc メッセージ中の「るな」を「瑠音」に置換。ただし「いるな」は除外。さらに「ななみ」を「七々美」に置換 v1.3
|
|
* @author ChatGPT
|
|
*
|
|
* @help
|
|
* このプラグインを導入すると、メッセージウィンドウ内で
|
|
* ・「るな」 → 「瑠音」(※直前が「い」の場合=「いるな」は変換しません)
|
|
* ・「ななみ」→ 「七々美」
|
|
* に自動で置き換えられます。
|
|
*
|
|
* 例:
|
|
* ×「いるなんて」→ 変換されずそのまま
|
|
* ○「るなが来た」→ 「瑠音が来た」
|
|
*
|
|
* 制御文字(\C[n] や \V[n] など)も問題なく使えます。
|
|
*/
|
|
|
|
(() => {
|
|
const _convertEscapeCharacters = Window_Message.prototype.convertEscapeCharacters;
|
|
Window_Message.prototype.convertEscapeCharacters = function(text) {
|
|
text = _convertEscapeCharacters.call(this, text);
|
|
|
|
// 「ななみ」→「七々美」
|
|
text = text.replace(/ななみ/g, "七々美");
|
|
|
|
// 「るな」→「瑠音」 ただし直前が「い」の場合(いるな)は除外
|
|
text = text.replace(/るな/g, (match, offset, string) => {
|
|
const prevChar = offset > 0 ? string[offset - 1] : "";
|
|
return prevChar === "い" ? match : "瑠音";
|
|
});
|
|
|
|
return text;
|
|
};
|
|
})();
|