楼主: 小兵的大刀

求教:如何改变战斗信息里的数字颜色

  [复制链接]

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-2-16 11:56:37 | 显示全部楼层
{/cy}修改完成
Window_BattleMessage倒数最後两句

  1.     self.contents.font.color = normal_color
  2.     self.contents.draw_text(rect, @lines[index])
复制代码

替换成

  1.    while ((c = text.slice!(/./m)) != nil)
  2.      # \C[n] 的情況下
  3.      if c == "\001"
  4.        # 更改文字色
  5.        text.sub!(/\[([0-9]+)\]/, "")
  6.        color = $1.to_i
  7.        if color >= 0 and color <= 31
  8.          self.contents.font.color = text_color(color)
  9.        else
  10.          self.contents.font.color = text_color(0)
  11.        end
  12.        # 下面的文字
  13.        next
  14.      end
  15.      if c == "\n"
  16.        y += [24, 0].max
  17.        x = 0
  18.        next
  19.      end
  20.      if x+22 > 353
  21.        y += [24, 0].max
  22.        x = 0
  23.      end
  24.      x+= 22
  25.      self.contents.draw_text(x, y, 348, 24, c)
  26.    end
复制代码


然後在要修改的字串前面加上\\c[n]
n为窗口外观下面两格的颜色代号(0~31)
超出0~31的范围会自动用白色显示

效果图:

系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-2-11
回帖
143
 楼主| 发表于 2008-2-16 11:59:47 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-2-16 12:04:51 | 显示全部楼层
不好意思,修改一下,之前那个是包含了我自己在用的换行功能,
如果LZ不需要的话就用下面这个吧:

  1.    while ((c = text.slice!(/./m)) != nil)
  2.      # \C[n] 的情況下
  3.      if c == "\001"
  4.        # 更改文字色
  5.        text.sub!(/\[([0-9]+)\]/, "")
  6.        color = $1.to_i
  7.        if color >= 0 and color <= 31
  8.          self.contents.font.color = text_color(color)
  9.        else
  10.          self.contents.font.color = text_color(0)
  11.        end
  12.        # 下面的文字
  13.        next
  14.      end
  15.      self.contents.draw_text(rect, 348, 24, c)
  16.    end
复制代码
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-2-11
回帖
143
 楼主| 发表于 2008-2-16 12:11:21 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-2-16 13:18:43 | 显示全部楼层
不好意思,没有经过极限测试
出现了些许BUG
请用这个(替代上面那个脚本)


  1.     self.contents.font.color = normal_color
  2.    text = @lines[index].clone
  3.    while ((c = text.slice!(/./m)) != nil)
  4.      # \C[n] 的情況下
  5.      if c == "\001"
  6.        # 更改文字色
  7.        text.sub!(/\[([0-9]+)\]/, "")
  8.        color = $1.to_i
  9.        if color >= 0 and color <= 31
  10.          self.contents.font.color = text_color(color)
  11.        else
  12.          self.contents.font.color = text_color(0)
  13.        end
  14.        # 下面的文字
  15.        next
  16.      end
  17.      c_width = contents.text_size(c).width
  18.      rect.x+= c_width
  19.      self.contents.draw_text(rect.x, rect.y, 348, 24, c)
  20.    end   
复制代码
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部