找回密码
 注册
搜索
查看: 1177|回复: 15

用mush来做颜色触发的实现

[复制链接]
门派:桃花岛
发表于 2021-2-7 22:00:10 | 显示全部楼层 |阅读模式
<!-- Produced by MUSHclient v 4.84 - www.mushclient.com -->

<font size=2 face="Ubuntu Mono, FixedSys, Lucida Console, Courier New, Courier">
你目前已经拥有了二件私有装备:三才风云剑,清风剑
Styles #1
文本内容:       你目前已经拥有了二件私有装备:
颜色代码:       32768
颜色名称:       green
Styles #2
文本内容:       ⊕
颜色代码:       255
颜色名称:       red
Styles #3
文本内容:       三才
颜色代码:       32768
颜色名称:       green
Styles #4
文本内容:       风云剑
颜色代码:       16711935
颜色名称:       magenta
Styles #5
文本内容:       ,
颜色代码:       32768
颜色名称:       green
Styles #6
文本内容:       ⊕
颜色代码:       255
颜色名称:       red
Styles #7
文本内容:       清风剑
颜色代码:       16777215
颜色名称:       white
Styles #8
文本内容:       。
颜色代码:       32768
颜色名称:       green

这是一个示例。

新建了一个trigger
create_trigger_t('testcolortrigger',"你目前已经拥有了二件私有装备:⊕三才风云剑,⊕清风剑。",'','colortesttrigger')

触发后调用colortesttrigger

function colortesttrigger(n,l,w)
    line_num = GetLinesInBufferCount()
    styles_num = GetLineInfo(line_num,11)
   
    for i = 1,styles_num do
        textContent = GetStyleInfo(line_num,i,1)
        textColorCode = GetStyleInfo(line_num,i,14)
        textColorName = RGBColourToName(textColorCode)

        print("Styles #"..i)
        print("文本内容:\t"..textContent.."\n颜色代码:\t"..textColorCode.."\n颜色名称:\t"..textColorName)
    end
end



红色部分就是用来获取对应文本内容、颜色代码和颜色名称的。

评分

1

查看全部评分

门派:明教
发表于 2021-2-9 16:16:08 | 显示全部楼层
冬至兄,白虎装备抓出来是什么颜色代码?为啥我们显示都是绿色,而老板说是白色呢?
门派:桃花岛
 楼主| 发表于 2021-2-7 22:10:36 | 显示全部楼层
styles_num就是通过 GetLineInfo(line_num,11)来获取改文本行所使用的的不同风格的个数  11: count of style runs (long)

GetStyleInfo(line_num, i, 1) 获取line_num所在行第i种风格所对应的文本
GetStyleInfo(line_num, i, 14) 获取line_num所在行第i种风格所对应的RGB色彩代码

门派:古墓派
发表于 2021-2-7 22:31:09 | 显示全部楼层
https://www.mushclient.com/scripts/function.php?name=GetStyleInfo

VARIANT GetStyleInfo(long LineNumber, long StyleNumber, short InfoType);

1: text of style (string)
2: length of style run (short)
3: starting column of style (short)
4: action type - 0=none, 1=send to mud, 2=hyperlink, 3=prompt (short)
5: action (eg. what to send) (string)
6: hint (what to show) (string)
7: variable (variable to set) (string)
8: true if bold (boolean)
9: true if underlined (boolean)
10: true if blinking (boolean)
11: true if inverse (boolean)
12: true if changed by trigger from original (boolean)
13: true if start of a tag (action is tag name) (boolean)
14: foreground (text) colour in RGB (long)
15: background colour in RGB (long)
门派:古墓派
发表于 2021-2-7 22:46:35 | 显示全部楼层
这个处理起来有点麻烦呀
门派:桃花岛
 楼主| 发表于 2021-2-7 22:57:21 | 显示全部楼层
joyce@tj 发表于 2021-2-7 22:46
这个处理起来有点麻烦呀

这个只是用来拆解颜色和文本,后面通过匹配文本内容和颜色就可以按需执行了
门派:明教
发表于 2021-2-7 22:58:03 | 显示全部楼层
颜色出发好像不错啊,有点意思
门派:古墓派
发表于 2021-2-7 23:01:34 | 显示全部楼层
aws@tj 发表于 2021-2-7 22:57
这个只是用来拆解颜色和文本,后面通过匹配文本内容和颜色就可以按需执行了

有啥应用场景么。暂时想不出有啥地方需要用
门派:桃花岛
 楼主| 发表于 2021-2-7 23:09:42 | 显示全部楼层
joyce@tj 发表于 2021-2-7 23:01
有啥应用场景么。暂时想不出有啥地方需要用

我正好在判定出口的时候,能走通的房间是红色,不能走通的都是银色。
因为出口固定,根据时间不同出口会时通时闭,所以通过颜色会比较容易判定,其实这里也可以仅仅通过styles_num个数来直接判定
<!-- Produced by MUSHclient v 4.84 - www.mushclient.com -->


nw n ne
w r e
sw
s se






<!-- Produced by MUSHclient v 4.84 - www.mushclient.com -->


nw n ne
w r e
sw
s se


门派:姑苏慕容
发表于 2021-2-8 16:30:02 | 显示全部楼层
joyce@tj 发表于 2021-2-7 23:01
有啥应用场景么。暂时想不出有啥地方需要用

有应用场景的,比如判断武功颜色,防止误判
门派:古墓派
发表于 2021-2-8 19:15:44 | 显示全部楼层
ryru@tj 发表于 2021-2-8 16:30
有应用场景的,比如判断武功颜色,防止误判

这个基本都能解决的呀
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-4 21:10 , Processed in 0.033308 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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