查看: 1414|回复: 3

[有事请教] 脚本显示文章, 怎么设置文字颜色

[复制链接]
梦石
0
星屑
5410
在线时间
247 小时
注册时间
2020-5-21
回帖
32
发表于 2023-8-22 22:19:11 | 显示全部楼层 |阅读模式
悬赏100星屑已解决
     const text = `啊啊啊啊 。\\C[3] 一直在等你`;
怎么把 \c[3]的颜色设置成自己想要的 "#98f5ff"  这种代码颜色

最佳答案

查看完整内容

// 转义序列增强,支持\C[_RRGGBB]变色 Window_Base.prototype.obtainEscapeParam = function (textState) { const regExp = /^\[-?\w+\]/; // 转义序列的方括号内支持负整数、字母、下划线 const arr = regExp.exec(textState.text.slice(textState.index)); if (arr) { textState.index += arr[0].length; if (arr[0].startsWith('[_')) return arr[0].substring(2, arr[0].length - 1); // 下划线 ...
梦石
2
星屑
8479
在线时间
463 小时
注册时间
2021-12-4
回帖
486

MZ评测员

发表于 2023-8-22 22:19:12 | 显示全部楼层
// 转义序列增强,支持\C[_RRGGBB]变色
Window_Base.prototype.obtainEscapeParam = function (textState) {
    const regExp = /^\[-?\w+\]/; // 转义序列的方括号内支持负整数、字母、下划线
    const arr = regExp.exec(textState.text.slice(textState.index));
    if (arr) {
        textState.index += arr[0].length;
        if (arr[0].startsWith('[_')) return arr[0].substring(2, arr[0].length - 1); // 下划线开头
        return parseInt(arr[0].slice(1));
    } else
        return "";
};
Window_Base.prototype.processColorChange = function (colorIndex) { // \C[n]变色增强,支持RGB值
    if (typeof colorIndex === 'string') this.changeTextColor('#' + colorIndex);
    else this.changeTextColor(ColorManager.textColor(colorIndex));
};
回复

使用道具 举报

梦石
0
星屑
7771
在线时间
1525 小时
注册时间
2013-12-3
回帖
303
发表于 2023-8-22 23:13:28 | 显示全部楼层
\img\system\Window.png
看到图片右下角32个色块了吗

分别对应\c[0]到\c[31]一共32种颜色
直接把你要的颜色盖进去然后用\c调用就行
正常来讲32个预设位置应该足够用了吧
回复

使用道具 举报

梦石
0
星屑
5410
在线时间
247 小时
注册时间
2020-5-21
回帖
32
 楼主| 发表于 2023-8-23 00:31:23 | 显示全部楼层
HM495 发表于 2023-8-22 23:13
\img\system\Window.png
看到图片右下角32个色块了吗

但是我想要这种 #ffffff 代码 显示出来, 这样显示的颜色丰富多彩一点
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部