查看: 2647|回复: 5

[有事请教] 求助关于替换文本内容

[复制链接]
梦石
0
星屑
546
在线时间
59 小时
注册时间
2017-8-23
回帖
6
发表于 2024-3-10 01:30:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
之前有看到MV自带的\v[n] 用来将文本替换为变量,想问问这个是怎么实现的。
主要是该如何检测和替换文本中的 \v[n]  麻烦大佬们了
梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-3-10 09:57:17 | 显示全部楼层
你说的这个是转义字符,直接把n替换为你想要输入的变量序号就行了
比如\V[110],就是显示110号变量的值
除了显示变量,转义字符还有很多其他类型可以使用,也可以嵌套或结合使用,多看教程
QQ截图20240310095658.png
回复

使用道具 举报

梦石
0
星屑
546
在线时间
59 小时
注册时间
2017-8-23
回帖
6
 楼主| 发表于 2024-3-10 15:01:49 | 显示全部楼层
shiroin 发表于 2024-3-10 09:57
你说的这个是转义字符,直接把n替换为你想要输入的变量序号就行了
比如\V[110],就是显示110号变量的值
除 ...

首先感谢大佬回复
然后其实我是想知道有关代码层面的。。。
我看别的大佬写的插件有类似的效果,想问问插件里都是怎么写的
回复

使用道具 举报

梦石
0
星屑
3264
在线时间
777 小时
注册时间
2023-5-18
回帖
154
发表于 2024-3-10 15:29:50 | 显示全部楼层
可能是这个
[pre lang="javascript"]Window_Base.prototype.convertEscapeCharacters = function(text) {
    text = text.replace(/\\/g, '\x1b');
    text = text.replace(/\x1b\x1b/g, '\\');
    text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
        return $gameVariables.value(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
        return $gameVariables.value(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
        return this.actorName(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
        return this.partyMemberName(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
    return text;
};[/pre]
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复

使用道具 举报

梦石
0
星屑
546
在线时间
59 小时
注册时间
2017-8-23
回帖
6
 楼主| 发表于 2024-3-10 16:36:35 | 显示全部楼层
Arrose 发表于 2024-3-10 15:29
可能是这个
Window_Base.prototype.convertEscapeCharacters = function(text) {
    text = text.replace( ...

谢谢大佬
回复

使用道具 举报

梦石
0
星屑
228
在线时间
25 小时
注册时间
2022-11-20
回帖
8
发表于 2024-3-14 04:16:56 | 显示全部楼层
牛逼啊,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部