查看: 4261|回复: 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
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-9-7 21:13:50 | 显示全部楼层
本帖最后由 喵呜喵5 于 2013-9-8 13:38 编辑
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Message_Advanced
  4. #------------------------------------------------------------------------------
  5. #   使对话框略微美观一点
  6. #   调用方式:在对话内容的第一行输入“l/r”+“对话者姓名”
  7. #   l和r表示头像在左边或者右边显示,对话者姓名显示在头像下方
  8. #   第一行输入“no”则为取消使用
  9. #==============================================================================

  10. class Game_Message
  11.   #--------------------------------------------------------------------------
  12.   # ● 定义实例变量
  13.   #--------------------------------------------------------------------------
  14.   attr_reader   :talker_name              # 说话者姓名
  15.   attr_reader   :talker_mirror            # 是否镜象显示
  16.   #--------------------------------------------------------------------------
  17.   # ● 清除
  18.   #--------------------------------------------------------------------------
  19.   def clear
  20.     @texts = []
  21.     @choices = []
  22.     # 初始化
  23.     @talker_name = ""
  24.     @talker_mirror = false
  25.     @face_name = ""
  26.     @face_index = 0
  27.     @background = 0
  28.     @position = 2
  29.     @choice_cancel_type = 0
  30.     @choice_proc = nil
  31.     @num_input_variable_id = 0
  32.     @num_input_digits_max = 0
  33.     @item_choice_variable_id = 0
  34.     @scroll_mode = false
  35.     @scroll_speed = 2
  36.     @scroll_no_fast = false
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 获取包括换行符的所有内容
  40.   #--------------------------------------------------------------------------
  41.   def all_text
  42.     if @texts.size > 1
  43.     # 取出第一个字符        
  44.       ch = texts[0].slice(0, 1)
  45.       if ch == "l" or ch=="r"
  46.         # 当右侧显示头像时设置mirror标志
  47.         @talker_mirror = true if ch == "r"
  48.         @talker_name = "[" + texts[0].slice(1,@texts[0].size - 1) + "]"
  49.         # 删除第一行控制内容
  50.         @texts.delete_at(0)        
  51.       end
  52.     end
  53.     @texts.inject("") {|r, text| r += text + "\n" }
  54.   end
  55. end


  56. class Window_Message < Window_Base
  57.   #--------------------------------------------------------------------------
  58.   # ● 处理纤程的主逻辑
  59.   #--------------------------------------------------------------------------
  60.   def fiber_main
  61.     $game_message.visible = true
  62.     update_background
  63.     update_placement
  64.     loop do
  65.       # 生成显示精灵
  66.       @face_sprite = Sprite.new
  67.       @name_sprite = Sprite.new
  68.       process_all_text if $game_message.has_text?
  69.       process_input
  70.       # 将显示精灵释放
  71.       @face_sprite.dispose
  72.       @name_sprite.dispose
  73.       $game_message.clear
  74.       @gold_window.close
  75.       Fiber.yield
  76.       break unless text_continue?
  77.     end
  78.     close_and_wait
  79.     $game_message.visible = false
  80.     @fiber = nil
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 翻页处理
  84.   #--------------------------------------------------------------------------
  85.   def new_page(text, pos)
  86.     contents.clear
  87.     if !$game_message.talker_name.empty?
  88.       # 判断左右侧显示
  89.       if $game_message.talker_mirror      
  90.         draw_face_right($game_message.face_name,$game_message.face_index)
  91.         draw_name_right($game_message.talker_name)
  92.       else
  93.         draw_face_left($game_message.face_name,$game_message.face_index)
  94.         draw_name_left($game_message.talker_name)
  95.       end
  96.     else
  97.       draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  98.     end
  99.     reset_font_settings
  100.     pos[:x] = new_line_x
  101.     pos[:y] = 0
  102.     pos[:new_x] = new_line_x
  103.     pos[:height] = calc_line_height(text)
  104.     clear_flags
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 显示说话者脸图(左)
  108.   #--------------------------------------------------------------------------
  109.   def draw_face_left(face_name, face_index)
  110.     # 取出图片
  111.     source = Cache.face(face_name)
  112.     # 找到脸图位置
  113.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  114.     bitmap = Bitmap.new(96, 96)
  115.     # 复制到bitmap中
  116.     bitmap.blt(0, 0, source, rect)
  117.     # 计算精灵位置并显示
  118.     @face_sprite.x = standard_padding
  119.     @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
  120.     @face_sprite.z = 1000
  121.     @face_sprite.bitmap = bitmap
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 显示说话者脸图(右)
  125.   #--------------------------------------------------------------------------
  126.   def draw_face_right(face_name, face_index)
  127.     source = Cache.face(face_name)
  128.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  129.     bitmap = Bitmap.new(96, 96)
  130.     bitmap.blt(0, 0, source, rect)
  131.     @face_sprite.x = Graphics.width - 96 - standard_padding
  132.     @face_sprite.y = Graphics.height - 96 - standard_padding - line_height
  133.     @face_sprite.z = 1000
  134.     # 设置为右侧显示
  135.     @face_sprite.mirror = true
  136.     @face_sprite.bitmap = bitmap
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 显示说话者姓名图(左)
  140.   #--------------------------------------------------------------------------
  141.   def draw_name_left(talker_name)
  142.     bitmap = Bitmap.new(96, line_height)
  143.     # 描绘姓名图像
  144.     bitmap.draw_text(bitmap.rect, talker_name, 1)
  145.     # 计算精灵位置并显示
  146.     @name_sprite.x = standard_padding
  147.     @name_sprite.y = Graphics.height - standard_padding - line_height
  148.     @name_sprite.z = 1000
  149.     @name_sprite.bitmap = bitmap
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 显示说话者姓名图(右)
  153.   #--------------------------------------------------------------------------
  154.   def draw_name_right(talker_name)
  155.     bitmap = Bitmap.new(96, line_height)
  156.     bitmap.draw_text(bitmap.rect, talker_name, 1)
  157.     @name_sprite.x = Graphics.width - 96 - standard_padding
  158.     @name_sprite.y = Graphics.height - standard_padding - line_height
  159.     @name_sprite.z = 1000
  160.     @name_sprite.bitmap = bitmap
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 获取换行位置
  164.   #--------------------------------------------------------------------------
  165.   def new_line_x
  166.     if !$game_message.talker_mirror
  167.       return $game_message.face_name.empty? ? 0 : 112
  168.     # 右侧显示时,换行显示位置为行首
  169.     else
  170.       return 0
  171.     end
  172.   end
  173. end
复制代码


顺便给自己的姓名显示脚本打广告: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
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 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.

在本版发帖返回顶部