设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 471|回复: 3
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3169
在线时间
220 小时
注册时间
2020-5-21
帖子
49
跳转到指定楼层
1
发表于 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); // 下划线 ...

Lv4.逐梦者

梦石
0
星屑
5419
在线时间
389 小时
注册时间
2021-12-4
帖子
412
2
发表于 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));
};
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
5460
在线时间
1123 小时
注册时间
2013-12-3
帖子
266
3
发表于 2023-8-22 23:13:28 | 只看该作者
\img\system\Window.png
看到图片右下角32个色块了吗

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3169
在线时间
220 小时
注册时间
2020-5-21
帖子
49
4
 楼主| 发表于 2023-8-23 00:31:23 | 只看该作者
HM495 发表于 2023-8-22 23:13
\img\system\Window.png
看到图片右下角32个色块了吗

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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 00:14

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表