查看: 4165|回复: 12

[已经解决] 求各位大大帮忙完善个脚本!

[复制链接]
梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
发表于 2013-9-7 20:28:19 | 显示全部楼层 |阅读模式

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

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

×
http://rpg.blue/forum.php?mod=viewthread&tid=322633
这个地址的脚本,有一个BUG,每重复一次对话,然后头像下面的名字就缩小一个字节!
神马情况,求解决!!!!!谢谢各位大大了!
梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 20:36:25 | 显示全部楼层
而且左右变化也变回来了!!求解决啊!
在线等大神解答!
无标题.png
回复

使用道具 举报

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2013-9-7 21:13:50 | 显示全部楼层
本帖最后由 喵呜喵5 于 2013-9-8 13:38 编辑

[pre lang="ruby" line="1"]#encoding:utf-8
#==============================================================================
# ■ Message_Advanced
#------------------------------------------------------------------------------
#   使对话框略微美观一点
#   调用方式:在对话内容的第一行输入“l/r”+“对话者姓名”
#   l和r表示头像在左边或者右边显示,对话者姓名显示在头像下方
#   第一行输入“no”则为取消使用
#==============================================================================

class Game_Message
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :talker_name              # 说话者姓名
  attr_reader   :talker_mirror            # 是否镜象显示
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    @texts = []
    @choices = []
    # 初始化
    @talker_name = ""
    @talker_mirror = false
    @face_name = ""
    @face_index = 0
    @background = 0
    @position = 2
    @choice_cancel_type = 0
    @choice_proc = nil
    @num_input_variable_id = 0
    @num_input_digits_max = 0
    @item_choice_variable_id = 0
    @scroll_mode = false
    @scroll_speed = 2
    @scroll_no_fast = false
  end
  #--------------------------------------------------------------------------
  # ● 获取包括换行符的所有内容
  #--------------------------------------------------------------------------
  def all_text
    if @texts.size > 1
    # 取出第一个字符        
      ch = texts[0].slice(0, 1)
      if ch == "l" or ch=="r"
        # 当右侧显示头像时设置mirror标志
        @talker_mirror = true if ch == "r"
        @talker_name = "[" + texts[0].slice(1,@texts[0].size - 1) + "]"
        # 删除第一行控制内容
        @texts.delete_at(0)        
      end
    end
    @texts.inject("") {|r, text| r += text + "\n" }
  end
end


class Window_Message < Window_Base
  #--------------------------------------------------------------------------
  # ● 处理纤程的主逻辑
  #--------------------------------------------------------------------------
  def fiber_main
    $game_message.visible = true
    update_background
    update_placement
    loop do
      # 生成显示精灵
      @face_sprite = Sprite.new
      @name_sprite = Sprite.new
      process_all_text if $game_message.has_text?
      process_input
      # 将显示精灵释放
      @face_sprite.dispose
      @name_sprite.dispose
      $game_message.clear
      @gold_window.close
      Fiber.yield
      break unless text_continue?
    end
    close_and_wait
    $game_message.visible = false
    @fiber = nil
  end
  #--------------------------------------------------------------------------
  # ● 翻页处理
  #--------------------------------------------------------------------------
  def new_page(text, pos)
    contents.clear
    if !$game_message.talker_name.empty?
      # 判断左右侧显示
      if $game_message.talker_mirror      
        draw_face_right($game_message.face_name,$game_message.face_index)
        draw_name_right($game_message.talker_name)
      else
        draw_face_left($game_message.face_name,$game_message.face_index)
        draw_name_left($game_message.talker_name)
      end
    else
      draw_face($game_message.face_name, $game_message.face_index, 0, 0)
    end
    reset_font_settings
    pos[:x] = new_line_x
    pos[:y] = 0
    pos[:new_x] = new_line_x
    pos[:height] = calc_line_height(text)
    clear_flags
  end
  #--------------------------------------------------------------------------
  # ● 显示说话者脸图(左)
  #--------------------------------------------------------------------------
  def draw_face_left(face_name, face_index)
    # 取出图片
    source = Cache.face(face_name)
    # 找到脸图位置
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    bitmap = Bitmap.new(96, 96)
    # 复制到bitmap中
    bitmap.blt(0, 0, source, rect)
    # 计算精灵位置并显示
    @face_sprite.x = standard_padding
    @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
    @face_sprite.z = 1000
    @face_sprite.bitmap = bitmap
  end
  #--------------------------------------------------------------------------
  # ● 显示说话者脸图(右)
  #--------------------------------------------------------------------------
  def draw_face_right(face_name, face_index)
    source = Cache.face(face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    bitmap = Bitmap.new(96, 96)
    bitmap.blt(0, 0, source, rect)
    @face_sprite.x = Graphics.width - 96 - standard_padding
    @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
    @face_sprite.z = 1000
    # 设置为右侧显示
    @face_sprite.mirror = true
    @face_sprite.bitmap = bitmap
  end
  #--------------------------------------------------------------------------
  # ● 显示说话者姓名图(左)
  #--------------------------------------------------------------------------
  def draw_name_left(talker_name)
    bitmap = Bitmap.new(96, line_height)
    # 描绘姓名图像
    bitmap.draw_text(bitmap.rect, talker_name, 1)
    # 计算精灵位置并显示
    @name_sprite.x = standard_padding
    @name_sprite.y = Graphics.height - standard_padding - line_height
    @name_sprite.z = 1000
    @name_sprite.bitmap = bitmap
  end
  #--------------------------------------------------------------------------
  # ● 显示说话者姓名图(右)
  #--------------------------------------------------------------------------
  def draw_name_right(talker_name)
    bitmap = Bitmap.new(96, line_height)
    bitmap.draw_text(bitmap.rect, talker_name, 1)
    @name_sprite.x = Graphics.width - 96 - standard_padding
    @name_sprite.y = Graphics.height - standard_padding - line_height
    @name_sprite.z = 1000
    @name_sprite.bitmap = bitmap
  end
  #--------------------------------------------------------------------------
  # ● 获取换行位置
  #--------------------------------------------------------------------------
  def new_line_x
    if !$game_message.talker_mirror
      return $game_message.face_name.empty? ? 0 : 112
    # 右侧显示时,换行显示位置为行首
    else
      return 0
    end
  end
end[/pre]

顺便给自己的姓名显示脚本打广告:http://rpg.blue/home.php?mod=spa ... o=blog&id=11733

评分

参与人数 1梦石 +1 收起 理由
熊喵酱 + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 21:26:27 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 21:13
#encoding:utf-8
#==============================================================================
# ■ ...

可是这样名字只能显示两个字..为什么额...

点评

再次修改脚本,现在可以显示更多字同时也可以显示中括号了  发表于 2013-9-7 22:00
稍微修改了一下,现在可以显示更多字了,不过姓名左右的中括号没了……  发表于 2013-9-7 21:48
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 21:53:15 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 21:13
#encoding:utf-8
#==============================================================================
# ■ ...

完美解决了!没有括号还好点!
膜拜大神啊能留个联系方式么?以后有问题请教下,我最近才开始做游戏,到你的空间觉得好多脚本很好啊!

点评

有问题可以直接在这个提问区询问,很多人大大都会帮助你的,当然如果看到我会的问题我也会回答的  发表于 2013-9-7 21:55
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 22:01:16 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 21:13
#encoding:utf-8
#==============================================================================
# ■ ...

刚才发现,VA上面好多注释和对话都会溢出对话框怎么办!换行的话就输入不完全了/..
回复

使用道具 举报

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2013-9-7 22:10:13 | 显示全部楼层
373484107 发表于 2013-9-7 22:01
刚才发现,VA上面好多注释和对话都会溢出对话框怎么办!换行的话就输入不完全了/.. ...

注释和对话溢出对话框?什么意思?脚本编辑器的大小超过屏幕了?


………………如果你没有基础的Ruby语言知识你就默默忍着吧
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 22:22:03 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 22:10
注释和对话溢出对话框?什么意思?脚本编辑器的大小超过屏幕了?

像这个图的,本来好多Q的..结果很多都溢出了,看不到,字体太大了?
无标题.png

点评

http://bbs.66rpg.com/home.php?mod=space&uid=291206&do=blog&id=11571  发表于 2013-9-7 22:23
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-7 22:30:34 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 22:10
注释和对话溢出对话框?什么意思?脚本编辑器的大小超过屏幕了?

谢谢,你可是帮了大忙了。感谢!
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2013-9-7
回帖
11
 楼主| 发表于 2013-9-8 12:09:46 | 显示全部楼层
喵呜喵5 发表于 2013-9-7 22:10
注释和对话溢出对话框?什么意思?脚本编辑器的大小超过屏幕了?

这脚本在战斗的时候,出现写着“未定义'的对话框!怎么办?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部