查看: 1666|回复: 8

[已经解决] 请问如何在对话中让角色姓名后显示其他内容? 已解决

[复制链接]
梦石
0
星屑
1021
在线时间
90 小时
注册时间
2022-12-26
回帖
79
发表于 2023-7-13 16:33:53 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 爱羊真知己 于 2023-7-19 17:41 编辑

我用了喵呜喵5大佬的对话显示姓名脚本,请问如何在角色姓名后以相同字号、[237,125,49,255]颜色显示其他内容?(调用方式:\name[角色名]\other[其他内容],和角色名一样要加【】)
脚本如下:[pre lang="ruby"]=begin
===============================================================================
  对话显示姓名 By喵呜喵5
===============================================================================

【说明】

  通过在对话开头加入

    \name[姓名]

  可以在对话中显示姓名

  ( \name[姓名] 的后面不需要换行,另外,请注意对话框高度太小时系统会强制翻页)

=end
$m5script ||= {};$m5script[:M5Name20141004] = 20170807
module M5Name20141004
#==============================================================================
#  设定部分
#==============================================================================

  FONT = ["QTxiaotu"]

  # 姓名所使用的字体

  SIZE = 20

  # 姓名字体的大小

  VOCAB = "【%s】"

  # 姓名的显示方式,%s 表示姓名的文字,
  # 例如,默认的设置下,“\name[埃里克]”将在游戏中显示为“【埃里克】:”
  # 不需要的话,直接填写一个 %s 就好

  COLOR = Color.new(149,182,255,255)

  # 姓名的颜色,四个数值分别是R、G、B以及透明度

  SET = [false,false,false,true]

  # 中括号中以逗号分隔开的单词分别设置姓名是否加粗、斜体、有阴影、加边框
  # 需要的话填写true,不需要的话填写false

  OUT_COLOR = Color.new(0, 0, 0, 60)

  # 姓名边框的颜色,四个数值分别是R、G、B以及透明度

  ALIGN =  0

  # 姓名的对齐方式,0,1,2分别是居左、居中、居右

  NAME_X = 0

  # 姓名的X坐标,数值越大姓名位置越靠近屏幕右侧

  NAME_Y = 3

  # 姓名的Y坐标,数值越大姓名位置越靠近屏幕底部

  DISTANCE = 10

  # 对话与姓名的间距,数字越大间距越大

  BACK_Y = 0

  # 姓名背景的Y坐标,数值越大姓名位置越靠近屏幕底部

  BACK_HEIGHT = 6

  # 姓名背景的高度,数字越大高度越大

  COLOR1 = Color.new(255, 255, 255, 70)

  # 姓名的背景框左边的颜色,四个数值分别是R、G、B以及透明度

  COLOR2 = Color.new(255, 255, 255, 0)

  # 姓名的背景框右边的颜色,四个数值分别是R、G、B以及透明度
  # 不需要背景的话,两个颜色的透明度都填0就好了

#==============================================================================
#  设定结束
#==============================================================================
end
class Window_Message
  alias m5_20141004_convert_escape_characters convert_escape_characters
  def convert_escape_characters *arg
    @m5_name_20150304 = nil
    result = m5_20141004_convert_escape_characters *arg
    result.gsub!(/\eNAME\[(.+?)\]/i) { @m5_name_20150304 = $1; "" }
    result
  end
  alias m5_20141004_new_page new_page
  def new_page(text, pos)
    m5_20141004_new_page(text, pos)
    if @m5_name_20150304
      set = M5Name20141004

      temp = Bitmap.new(contents.width, contents.height)
      temp.font.name = set::FONT
      temp.font.size = set::SIZE
      temp.font.color = set::COLOR
      temp.font.out_color = set::OUT_COLOR
      temp.font.bold = set::SET[0]
      temp.font.italic = set::SET[1]
      temp.font.shadow = set::SET[2]
      temp.font.outline = set::SET[3]

      name = sprintf(set::VOCAB, @m5_name_20150304)
      name_height = temp.text_size(name).height
      temp.gradient_fill_rect(0, set::BACK_Y, temp.width - new_line_x,
        name_height + set::BACK_HEIGHT, set::COLOR1, set::COLOR2)
      temp.draw_text(set::NAME_X, set::NAME_Y, temp.width - new_line_x, name_height,
        name, set::ALIGN)
      contents.blt(new_line_x, 0, temp, temp.rect)
      temp.dispose

      pos[:y] += name_height + M5Name20141004::DISTANCE
      @m5_name_20150304 = nil
    end
  end
end[/pre]
求助各位大佬!
你好!
梦石
0
星屑
1021
在线时间
90 小时
注册时间
2022-12-26
回帖
79
 楼主| 发表于 2023-7-15 16:00:23 | 显示全部楼层
无人应答……
回复

使用道具 举报

梦石
0
星屑
1021
在线时间
90 小时
注册时间
2022-12-26
回帖
79
 楼主| 发表于 2023-7-17 16:06:09 | 显示全部楼层
自顶!!
回复

使用道具 举报

梦石
0
星屑
52
在线时间
5 小时
注册时间
2022-10-3
回帖
3
发表于 2023-7-18 19:06:16 | 显示全部楼层
下次用脚本的时候记得看简介。如图介绍里说的那样,\name[要输入的名字]就行了
回复

使用道具 举报

梦石
0
星屑
52
在线时间
5 小时
注册时间
2022-10-3
回帖
3
发表于 2023-7-18 19:11:55 | 显示全部楼层
kokodayo~ 发表于 2023-7-18 19:06
下次用脚本的时候记得看简介。如图介绍里说的那样,\name[要输入的名字]就行了 ...

阿这,对不起,我看走眼了。
要不试试RM系统自带的“ \{ “”和“ \C[n] ”?
具体的使用方法把鼠标放在“文字”的输入框内就可以看到了

点评

抛开颜色和字号不谈,用了这个脚本后输入完姓名是不需要手动换行的,也就导致无法在同行输入其他内容。  发表于 2023-7-18 21:29
回复

使用道具 举报

梦石
0
星屑
1021
在线时间
90 小时
注册时间
2022-12-26
回帖
79
 楼主| 发表于 2023-7-19 11:12:15 | 显示全部楼层
自顶   
回复

使用道具 举报

梦石
0
星屑
29896
在线时间
5733 小时
注册时间
2016-3-8
回帖
1653
发表于 2023-7-19 16:26:07 | 显示全部楼层
未命名.png
[pre lang="ruby"]=begin
===============================================================================
  对话显示姓名 By喵呜喵5
===============================================================================

【说明】

  通过在对话开头加入

    \name[姓名]

  可以在对话中显示姓名

  ( \name[姓名] 的后面不需要换行,另外,请注意对话框高度太小时系统会强制翻页)

=end
$m5script ||= {};$m5script[:M5Name20141004] = 20170807
module M5Name20141004
#==============================================================================
#  设定部分
#==============================================================================

  FONT = ["QTxiaotu"]

  # 姓名所使用的字体

  SIZE = 20

  # 姓名字体的大小

  VOCAB = "【%s】"

  # 姓名的显示方式,%s 表示姓名的文字,
  # 例如,默认的设置下,“\name[埃里克]”将在游戏中显示为“【埃里克】:”
  # 不需要的话,直接填写一个 %s 就好

  COLOR = Color.new(149,182,255,255)
  COLOR_OTHER = Color.new(237,125,49,255)##########

  # 姓名的颜色,四个数值分别是R、G、B以及透明度

  SET = [false,false,false,true]

  # 中括号中以逗号分隔开的单词分别设置姓名是否加粗、斜体、有阴影、加边框
  # 需要的话填写true,不需要的话填写false

  OUT_COLOR = Color.new(0, 0, 0, 60)

  # 姓名边框的颜色,四个数值分别是R、G、B以及透明度

  ALIGN =  0

  # 姓名的对齐方式,0,1,2分别是居左、居中、居右

  NAME_X = 0

  # 姓名的X坐标,数值越大姓名位置越靠近屏幕右侧

  NAME_Y = 3

  # 姓名的Y坐标,数值越大姓名位置越靠近屏幕底部

  DISTANCE = 10

  # 对话与姓名的间距,数字越大间距越大

  BACK_Y = 0

  # 姓名背景的Y坐标,数值越大姓名位置越靠近屏幕底部

  BACK_HEIGHT = 6

  # 姓名背景的高度,数字越大高度越大

  COLOR1 = Color.new(255, 255, 255, 70)

  # 姓名的背景框左边的颜色,四个数值分别是R、G、B以及透明度

  COLOR2 = Color.new(255, 255, 255, 0)

  # 姓名的背景框右边的颜色,四个数值分别是R、G、B以及透明度
  # 不需要背景的话,两个颜色的透明度都填0就好了

#==============================================================================
#  设定结束
#==============================================================================
end
class Window_Message
  alias m5_20141004_convert_escape_characters convert_escape_characters
  def convert_escape_characters *arg
    @m5_name_20150304 = nil
    result = m5_20141004_convert_escape_characters *arg
    result.gsub!(/\eNAME\[(.+?)\]/i) { @m5_name_20150304 = $1; "" }
    result.gsub!(/\eOTHER\[(.+?)\]/i) { @m5_other_20150304 = $1; "" }##########
    result
  end
  alias m5_20141004_new_page new_page
  def new_page(text, pos)
    m5_20141004_new_page(text, pos)
    if @m5_name_20150304
      set = M5Name20141004

      temp = Bitmap.new(contents.width, contents.height)
      temp.font.name = set::FONT
      temp.font.size = set::SIZE
      temp.font.color = set::COLOR
      temp.font.out_color = set::OUT_COLOR
      temp.font.bold = set::SET[0]
      temp.font.italic = set::SET[1]
      temp.font.shadow = set::SET[2]
      temp.font.outline = set::SET[3]

      name = sprintf(set::VOCAB, @m5_name_20150304)
      name_width = temp.text_size(name).width##########
      name_height = temp.text_size(name).height
      temp.gradient_fill_rect(0, set::BACK_Y, temp.width - new_line_x,
        name_height + set::BACK_HEIGHT, set::COLOR1, set::COLOR2)
      temp.draw_text(set::NAME_X, set::NAME_Y, temp.width - new_line_x, name_height,
        name, set::ALIGN)
      contents.blt(new_line_x, 0, temp, temp.rect)
      temp.dispose

      pos[:y] += name_height + M5Name20141004::DISTANCE
      @m5_name_20150304 = nil
    end
    ##########
    if @m5_other_20150304
#~       set = M5Name20141004
      
      temp = Bitmap.new(contents.width, contents.height)
      temp.font.name = set::FONT
      temp.font.size = set::SIZE
      temp.font.color = set::COLOR_OTHER
      temp.font.out_color = set::OUT_COLOR
      temp.font.bold = set::SET[0]
      temp.font.italic = set::SET[1]
      temp.font.shadow = set::SET[2]
      temp.font.outline = set::SET[3]
      
      name = sprintf(set::VOCAB, @m5_other_20150304)
      name_height = temp.text_size(name).height
#~       temp.gradient_fill_rect(0, set::BACK_Y, temp.width - new_line_x,
#~         name_height + set::BACK_HEIGHT, set::COLOR1, set::COLOR2)
      temp.draw_text(set::NAME_X + name_width, set::NAME_Y, temp.width - new_line_x, name_height,
        name, set::ALIGN)
      contents.blt(new_line_x, 0, temp, temp.rect)
      temp.dispose

#~       pos[:y] += name_height + M5Name20141004::DISTANCE
      @m5_other_20150304 = nil
    end
    ##########
  end
end[/pre]

点评

谢谢!  发表于 2023-7-19 17:40

评分

参与人数 1赞 +1 收起 理由
爱羊真知己 + 1 我很赞同

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部