Project1

标题: 事件中使用$game_temp.message_text,只显示后面的内容是怎么回事 [打印本页]

作者: 会喵呜的熊    时间: 2013-7-27 13:58
标题: 事件中使用$game_temp.message_text,只显示后面的内容是怎么回事
本帖最后由 会喵呜的熊 于 2013-7-27 16:17 编辑

脚本基本没改过,只在Window_Message里面改了对话窗口大小(12行以及173-178行)。另外改了Window_Help,去掉了显示技能和状态(?)的部分(这个应该无关?)。

在事件执行页里添加如下内容:
脚本:
$game_temp.message_text= "xxxxxxx"
脚本:
$game_temp.message_text= "yyyyyyy"
则只显示yyyyyyy。

如果添加:
脚本:
$game_temp.message_text= "xxxxxxx"
等待:20桢
脚本:
$game_temp.message_text= "yyyyyyy"
在xxxxxxx出现的20帧(两秒?)之内按回车,会正常出现yyyyyyy。但是如果过了时间,第二个对话框就不会出现了。

有什么办法可以让用脚本输入的文字像普通输入的文字一样显示(回车以后显示下面的文字)吗?谢谢。
作者: 紫英晓狼1130    时间: 2013-7-27 14:32
最简单的方式就是添加独立开关了


范例在下面
Project2.zip (200.75 KB, 下载次数: 29)
作者: 会喵呜的熊    时间: 2013-7-27 14:44
紫英晓狼1130 发表于 2013-7-27 14:32
最简单的方式就是添加独立开关了

谢谢!由于需要输入的文字量比较大,每个都用独立开关操作可能不太实际。于是这等于是说无法用$game_temp.message_text达到和输入文章指令一样的效果吗?
作者: Wind2010    时间: 2013-7-27 14:47
脚本1
循环
—条件分歧:按下C
——中断循环
—分歧结束
中断循环
脚本2
作者: 美丽晨露    时间: 2013-7-27 15:12
本帖最后由 美丽晨露 于 2013-7-27 15:14 编辑

楼主可以使用长文本脚本解决输入文章过长的问题。

RUBY 代码复制
  1. class Window_Message < Window_Selectable
  2. def reset_window_stars(line_max)
  3.    if $game_temp.in_battle
  4.      self.y = 16
  5.    else
  6.      case $game_system.message_position
  7.      when 0  # 上
  8.        self.y = 16
  9.      when 1  # 中
  10.        self.y = 160
  11.      when 2  # 下
  12.        self.y = 304
  13.      end
  14.      self.height = 32 * (line_max + 1)
  15.      self.contents = Bitmap.new(self.width - 32, self.height - 32)
  16.    end
  17.    if $game_system.message_frame == 0
  18.      self.opacity = 255
  19.    else
  20.      self.opacity = 0
  21.    end
  22.    self.back_opacity = 160
  23. end
  24. #--------------------------------------------------------------------------
  25. # ● 刷新画面
  26. #--------------------------------------------------------------------------
  27. def update(line_max = 4)
  28.    super()
  29.    # 渐变的情况下
  30.    if @fade_in
  31.      self.contents_opacity += 24
  32.      if @input_number_window != nil
  33.        @input_number_window.contents_opacity += 24
  34.      end
  35.      if self.contents_opacity == 255
  36.        @fade_in = false
  37.      end
  38.      return
  39.    end
  40.    # 输入数值的情况下
  41.    if @input_number_window != nil
  42.      @input_number_window.update
  43.      # 确定
  44.      if Input.trigger?(Input::C)
  45.        $game_system.se_play($data_system.decision_se)
  46.        $game_variables[$game_temp.num_input_variable_id] =
  47.          @input_number_window.number
  48.        $game_map.need_refresh = true
  49.        # 释放输入数值窗口
  50.        @input_number_window.dispose
  51.        @input_number_window = nil
  52.        terminate_message
  53.      end
  54.      return
  55.    end
  56.    # 显示信息中的情况下
  57.    if @contents_showing
  58.      # 如果不是在显示选择项中就显示暂停标志
  59.      if $game_temp.choice_max == 0
  60.        self.pause = true
  61.      end
  62.      # 取消
  63.      if Input.trigger?(Input::B)
  64.        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  65.          $game_system.se_play($data_system.cancel_se)
  66.          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  67.          terminate_message
  68.        end
  69.      end
  70.      # 确定
  71.      if Input.trigger?(Input::C)
  72.        if $game_temp.choice_max > 0
  73.          $game_system.se_play($data_system.decision_se)
  74.          $game_temp.choice_proc.call(self.index)
  75.        end
  76.        terminate_message
  77.      end
  78.      return
  79.    end
  80.    # 在渐变以外的状态下有等待显示的信息与选择项的场合
  81.    if @fade_out == false and $game_temp.message_text != nil
  82.      @contents_showing = true
  83.      $game_temp.message_window_showing = true
  84.      reset_window_stars(line_max)
  85.      refresh
  86.      Graphics.frame_reset
  87.      self.visible = true
  88.      self.contents_opacity = 0
  89.      if @input_number_window != nil
  90.        @input_number_window.contents_opacity = 0
  91.      end
  92.      @fade_in = true
  93.      return
  94.    end
  95.    # 没有可以显示的信息、但是窗口为可见的情况下
  96.    if self.visible
  97.      @fade_out = true
  98.      self.opacity -= 48
  99.      if self.opacity == 0
  100.        self.visible = false
  101.        @fade_out = false
  102.        $game_temp.message_window_showing = false
  103.      end
  104.      return
  105.    end
  106. end
  107. end  
  108. class Interpreter
  109. attr_reader :line_max
  110. alias sailcat_clear clear
  111. def clear
  112.   sailcat_clear
  113.   @line_max = 4  # 信息最大行数
  114. end
  115. #--------------------------------------------------------------------------
  116. # ● 显示文章
  117. #--------------------------------------------------------------------------
  118. def command_101
  119.   # 另外的文章已经设置过 message_text 的情况下
  120.   if $game_temp.message_text != nil
  121.     # 结束
  122.     return false
  123.   end
  124.   # 设置信息结束后待机和返回调用标志
  125.   @message_waiting = true
  126.   $game_temp.message_proc = Proc.new { @message_waiting = false }
  127.   # message_text 设置为第 1 行
  128.   $game_temp.message_text = @list[@index].parameters[0] + "\n"
  129.   line_count = 1      
  130.   # 循环
  131.   loop do
  132.     # 下一个事件指令为文章两行以上的情况
  133.     if @list[@index+1].code == 401
  134.       # message_text 添加到第 2 行以下
  135.       $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
  136.       line_count += 1
  137.     # 下一个事件指令为显示文章并且是长文的情况
  138.     elsif @line_max != 4 and @list[@index+1].code == 101
  139.       # 如果文章长度足够
  140.       if line_count < @line_max
  141.         # message_text 添加到现有文章以后
  142.         $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
  143.         line_count += 1
  144.       # 文章长度不够的情况下
  145.       else
  146.         # 继续
  147.         return true
  148.       end
  149.     # 事件指令不在文章两行以下的情况
  150.     else
  151.       # 下一个事件指令为显示选择项的情况下
  152.       if @list[@index+1].code == 102
  153.         # 如果选择项能收纳在画面里
  154.         if @list[@index+1].parameters[0].size <= @line_max - line_count
  155.           # 推进索引
  156.           [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  157.           # 设置选择项
  158.           $game_temp.choice_start = line_count
  159.           setup_choices(@list[@index].parameters)
  160.         end
  161.       # 下一个事件指令为处理输入数值的情况下
  162.       elsif @list[@index+1].code == 103
  163.         # 如果数值输入窗口能收纳在画面里
  164.         if line_count < @line_max
  165.           # 推进索引
  166.           @index += 1
  167.           # 设置输入数值
  168.           $game_temp.num_input_start = line_count
  169.           $game_temp.num_input_variable_id = @list[@index].parameters[0]
  170.           $game_temp.num_input_digits_max = @list[@index].parameters[1]
  171.         end
  172.       end
  173.       # 继续
  174.       return true
  175.     end
  176.     # 推进索引
  177.     @index += 1
  178.   end
  179. end
  180. #--------------------------------------------------------------------------
  181. # ● 注释
  182. #--------------------------------------------------------------------------
  183. def command_108
  184.   # 注释关键字解释
  185.   case @parameters[0]
  186.   # 长文开始标记
  187.   when "LN_start"
  188.     if $game_temp.in_battle
  189.       @line_max = 4
  190.     else
  191.       case $game_system.message_position
  192.       when 0
  193.         @line_max = 12
  194.       when 1
  195.         @line_max = 8
  196.       when 2
  197.         @line_max = 4
  198.       end
  199.     end
  200.   # 长文结束标记
  201.   when "LN_end"
  202.     @line_max = 4
  203.   end
  204.   # 继续
  205.   return true
  206. end
  207. end
  208.  
  209. class Scene_Map
  210. #--------------------------------------------------------------------------
  211. # ● 刷新画面
  212. #--------------------------------------------------------------------------
  213. def update
  214.    # 循环
  215.    loop do
  216.      # 按照地图、实例、主角的顺序刷新
  217.      # (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
  218.      #  的机会的重要因素)
  219.      $game_map.update
  220.      $game_system.map_interpreter.update
  221.      $game_player.update
  222.      # 系统 (计时器)、画面刷新
  223.      $game_system.update
  224.      $game_screen.update
  225.      # 如果主角在场所移动中就中断循环
  226.      unless $game_temp.player_transferring
  227.        break
  228.      end
  229.      # 执行场所移动
  230.      transfer_player
  231.      # 处理过渡中的情况下、中断循环
  232.      if $game_temp.transition_processing
  233.        break
  234.      end
  235.    end
  236.    # 刷新活动块
  237.    @spriteset.update
  238.    # 刷新信息窗口
  239.    @message_window.update($game_system.map_interpreter.line_max)
  240.    # 游戏结束的情况下
  241.    if $game_temp.gameover
  242.      # 切换的游戏结束画面
  243.      $scene = Scene_Gameover.new
  244.      return
  245.    end
  246.    # 返回标题画面的情况下
  247.    if $game_temp.to_title
  248.      # 切换到标题画面
  249.      $scene = Scene_Title.new
  250.      return
  251.    end
  252.    # 处理过渡中的情况下
  253.    if $game_temp.transition_processing
  254.      # 清除过渡处理中标志
  255.      $game_temp.transition_processing = false
  256.      # 执行过渡
  257.      if $game_temp.transition_name == ""
  258.        Graphics.transition(20)
  259.      else
  260.        Graphics.transition(40, "Graphics/Transitions/" +
  261.          $game_temp.transition_name)
  262.      end
  263.    end
  264.    # 显示信息窗口中的情况下
  265.    if $game_temp.message_window_showing
  266.      return
  267.    end
  268.    # 遇敌计数为 0 且、且遇敌列表不为空的情况下
  269.    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  270.      # 不是在事件执行中或者禁止遇敌中
  271.      unless $game_system.map_interpreter.running? or
  272.             $game_system.encounter_disabled
  273.        # 确定队伍
  274.        n = rand($game_map.encounter_list.size)
  275.        troop_id = $game_map.encounter_list[n]
  276.        # 队伍有效的话
  277.        if $data_troops[troop_id] != nil
  278.          # 设置调用战斗标志
  279.          $game_temp.battle_calling = true
  280.          $game_temp.battle_troop_id = troop_id
  281.          $game_temp.battle_can_escape = true
  282.          $game_temp.battle_can_lose = false
  283.          $game_temp.battle_proc = nil
  284.        end
  285.      end
  286.    end
  287.    # 按下 B 键的情况下
  288.    if Input.trigger?(Input::B)
  289.      # 不是在事件执行中或菜单禁止中
  290.      unless $game_system.map_interpreter.running? or
  291.             $game_system.menu_disabled
  292.        # 设置菜单调用标志以及 SE 演奏
  293.        $game_temp.menu_calling = true
  294.        $game_temp.menu_beep = true
  295.      end
  296.    end
  297.    # 调试模式为 ON 并且按下 F9 键的情况下
  298.    if $DEBUG and Input.press?(Input::F9)
  299.      # 设置调用调试标志
  300.      $game_temp.debug_calling = true
  301.    end
  302.    # 不在主角移动中的情况下
  303.    unless $game_player.moving?
  304.      # 执行各种画面的调用
  305.      if $game_temp.battle_calling
  306.        call_battle
  307.      elsif $game_temp.shop_calling
  308.        call_shop
  309.      elsif $game_temp.name_calling
  310.        call_name
  311.      elsif $game_temp.menu_calling
  312.        call_menu
  313.      elsif $game_temp.save_calling
  314.        call_save
  315.      elsif $game_temp.debug_calling
  316.        call_debug
  317.      end
  318.    end
  319. end
  320. end

作者: 会喵呜的熊    时间: 2013-7-27 15:31
美丽晨露 发表于 2013-7-27 15:12
楼主可以使用长文本脚本解决输入文章过长的问题。

class Window_Message < Window_Selectable

对不起我很笨,在Main之前插入这个脚本后,显示156行Syntax Error,#掉156行以后显示110行Name Error。是不是除了插入这个脚本还需要做别的修改?谢谢。
作者: 美丽晨露    时间: 2013-7-27 15:44
url=home.php?mod=space&uid=370741@Index[/url] += 1
改为
@Index += 1
论坛代码插入有BUG得说
作者: 会喵呜的熊    时间: 2013-7-27 16:16
美丽晨露 发表于 2013-7-27 15:44
url=home.php?mod=space&uid=370741@Index[/url] += 1
改为
@Index += 1

大感谢!话说认同答案在哪里……




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1