| 
 
| 赞 | 168 |  
| VIP | 6 |  
| 好人卡 | 208 |  
| 积分 | 225 |  
| 经验 | 137153 |  
| 最后登录 | 2025-4-1 |  
| 在线时间 | 8598 小时 |  
 Lv5.捕梦者 
	梦石0 星屑22499 在线时间8598 小时注册时间2011-12-31帖子3361 | 
| 本帖最后由 tseyik 于 2013-11-11 17:28 编辑 
 選択肢拡張
 通常只有四個選擇顯示可以無限増加。
 
 
   LineMax = 4 改変LineMax的値可改変顯示選擇数量
 
   通過開関与変数等可變的條件,可以設置選項顯示是否。
 
   
   复制代码=begin
 ▼ 選択肢拡張 ver 1.3
 
 RPGツクールVXAce用スクリプト
 
 制作 : 木星ペンギン
 URL  : http://woodpenguin.blog.fc2.com/
------------------------------------------------------------------------------
 概要
 □ 選択肢を連続して設定した場合、つなげて一つの選択肢にする機能の追加。
 □ 条件を設定することで、その項目を表示しない機能の追加。
 □ 選択肢内容が前回と同じだった場合、
    カーソルの初期位置を前回選んだ項目にする機能の追加。
------------------------------------------------------------------------------
 使い方
 
 □ 選択肢を繋げる方法
  ・選択肢の表示を続けて配置すると、一つの選択肢にまとめられます。
  ・まとめたくない場合は、間に注釈などを入れることで通常通り分けることができます。
  ・「キャンセルの場合」の処理は、無効以外を設定したものが適用されます。
  ・「キャンセルの場合」の処理が複数ある場合、
   あとに設定された選択肢のものが適用されます。
  
 □ 条件によって、項目を表示させない方法
  ・選択肢の文章の最後に if(条件) と書くことで、
   その条件が偽になると項目が表示されなくなります。
  ・s でスイッチを参照できます。
     (例 : if(s[3]) でスイッチ番号 3 が ON のとき項目が表示されます)
  ・v で変数を参照できます。
     (例 : if(v[5] >= 4) で変数番号 5 が 4 以上のとき項目が表示されます)
  ・これらの条件は eval によって判定されてるので、and や or なども使用できます。
  ・この機能により選択肢の項目数が 0 となった場合、
   何も選択しなかったことになります。
   「キャンセルの場合」の処理が適用されるわけではありません。
  ・この機能により「キャンセルの場合」の項目が表示されない場合、
   無効と同じ処理をします。
=end
module Wooden
module ChoiceEX
#//////////////////////////////////////////////////////////////////////////////
#
# 設定項目
#
#//////////////////////////////////////////////////////////////////////////////
  #--------------------------------------------------------------------------
  # ● 選択肢の最大行数
  #     選択肢を表示するウィンドウの行数の最大数です。
  #     選択肢がこの数より小さければ、通常通り行数は少なくなります。
  #--------------------------------------------------------------------------
  LineMax = 4
  
  #--------------------------------------------------------------------------
  # ● 選択肢の位置記憶
  #     前回表示した選択肢と全く同じ内容の選択肢を表示する場合、
  #     カーソルの初期位置を前回選んだ項目にする機能です。
  #     false で無効化できます。
  #--------------------------------------------------------------------------
  Store = true
  
end
end
#//////////////////////////////////////////////////////////////////////////////
#
# 以降、変更する必要なし
#
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ☆ 選択肢のセットアップ
  #--------------------------------------------------------------------------
  def setup_choices(params)
    result = []
    add_choices(params, @index, result)
    unless $game_message.choices.empty?
      result << $game_message.choice_cancel_type - 1
      $game_message.choice_proc = Proc.new {|n| @branch[@indent] = result[n] }
    else
      @branch[@indent] = -1
    end
  end
  #--------------------------------------------------------------------------
  # ● 選択肢の追加
  #--------------------------------------------------------------------------
  def add_choices(params, i, result, d = 0)
    params[0].each_with_index do |s, n|
      choice = s.dup
      next if choice.slice!(/\s*if\((.+)\)$/i) && !choice_eval($1)
      $game_message.choices << choice
      result << n + d
    end
    if params[1] == 5 || (params[1] > 0 && result.include?(params[1] + d - 1))
      $game_message.choice_cancel_type = params[1] + d
    end
    indent = @list[i].indent
    i += 1 until @list[i].code == 404 && @list[i].indent == indent
    i += 1
    add_choices(@list[i].parameters, i, result, d + 5) if @list[i].code == 102
  end
  #--------------------------------------------------------------------------
  # ● 分岐終了の場合
  #--------------------------------------------------------------------------
  def choice_eval(formula)
    s = $game_switches
    v = $game_variables
    begin
      Kernel.eval(formula)
    rescue
      msgbox "以下の条件判定でエラーが出ました。\n\n", formula
      true
    end
  end
  #--------------------------------------------------------------------------
  # ● 分岐終了の場合
  #--------------------------------------------------------------------------
  def command_404
    if next_event_code == 102
      @branch[@indent] -= 5
      @Index+= 1
      command_skip
    end
  end
end
#==============================================================================
# ■ Window_ChoiceList
#==============================================================================
class Window_ChoiceList
  #--------------------------------------------------------------------------
  # ● 指定行数に適合するウィンドウの高さを計算
  #--------------------------------------------------------------------------
  def fitting_height(line_number)
    super([line_number, Wooden::ChoiceEX::LineMax].min)
  end
  #--------------------------------------------------------------------------
  # ☆ 入力処理の開始
  #--------------------------------------------------------------------------
  def start
    last_choices = @list.collect {|c| c[:name] }
    update_placement
    unless Wooden::ChoiceEX::Store && last_choices == $game_message.choices
      refresh
      select(0)
    end
    open
    activate
  end
  #--------------------------------------------------------------------------
  # ☆ キャンセルハンドラの呼び出し
  #--------------------------------------------------------------------------
  def call_cancel_handler
    $game_message.choice_proc.call(item_max)
    close
  end
end
 | 
 评分
查看全部评分
 |