设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2590|回复: 2
打印 上一主题 下一主题

[已经解决] 【搜索者请进】選択肢拡張 va 选项 增加 多选项

[复制链接]

Lv2.观梦者

梦石
0
星屑
429
在线时间
175 小时
注册时间
2013-11-2
帖子
131
跳转到指定楼层
1
发表于 2015-4-17 21:10:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 zy652301 于 2015-4-18 21:15 编辑

如果你要是用此脚本必须清楚:
1.此脚本可能会在使用指示符的时候产生极为恶劣的BUG。
2.此脚本可能会在跳转标签时产生引发强迫症的BUG。
我™已经放弃了(◕ω◕)。
最后感谢大家给我的帮助,虽然我已经放弃了。

RUBY 代码复制
  1. =begin
  2.  
  3.  ▼ 選択肢拡張 ver. 2.3
  4.  
  5.  RPGツクールVXAce用スクリプト
  6.  
  7.  制作 : 木星ペンギン
  8.  URL  : [url]http://woodpenguin.blog.fc2.com/[/url]
  9.  
  10. ------------------------------------------------------------------------------
  11.  概要
  12.  
  13.  □ 選択肢を連続して設定した場合、つなげて一つの選択肢にする機能の追加。
  14.  □ 条件を設定することで、その項目を表示しない機能の追加。
  15.  □ 選択肢内容が前回と同じだった場合、
  16.     カーソルの初期位置を前回選んだ項目にする機能の追加。
  17.  □ 選択肢ウィンドウの位置を一時的に変更する機能の追加。
  18.  □ 条件を設定することで、その項目を半透明にして選択不可にする機能の追加。
  19.  □ 選択肢毎にヘルプメッセージを表示できる機能の追加。
  20.  
  21. ------------------------------------------------------------------------------
  22.  使い方
  23.  
  24.  □ 選択肢の表示を続けて配置すると、一つの選択肢にまとめられます。
  25.   ・「キャンセルの場合」の処理は、無効以外を設定したものが適用され、
  26.      複数ある場合は後に設定された選択肢のものが適用されます。
  27.  
  28.  □ 選択肢の文章中に if(条件) と入れ、その条件が偽になると項目が表示されなくなります。
  29.   ・s でスイッチ、v で変数を参照できます。
  30.   ・「キャンセルの場合」の項目が表示されない場合、無効と同じ処理をします。
  31.  
  32.  □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの表示位置を
  33.    一時的に変更することが出来ます。
  34.  
  35.     選択肢位置(x, y[, row])
  36.     
  37.       x   : ウィンドウを表示する X 座標。
  38.       y   : ウィンドウを表示する Y 座標。
  39.       row : 選択肢を表示する最大行数。
  40.             指定しない場合は、通常の最大行数を無視して
  41.             すべての選択肢が表示されます。
  42.  
  43.  □ 選択肢の文章中に en(条件) と入れ、その条件が偽になると項目が半透明で表示されます。
  44.  
  45.  □ 各項目の下に、注釈で以下の文字列を入れると、続きの文章を
  46.     項目のヘルプメッセージとしてカーソルを合わせたときに標示することができます。
  47.  
  48.     選択肢ヘルプ
  49.     
  50.  □ 詳細は下記のサイトを参照してください。
  51.  
  52.   [url]http://woodpenguin.web.fc2.com/rgss3/choice_ex.html[/url]
  53.  
  54. =end
  55. module WdTk
  56. module ChoiceEX
  57. #//////////////////////////////////////////////////////////////////////////////
  58. #
  59. # 設定項目
  60. #
  61. #//////////////////////////////////////////////////////////////////////////////
  62.   #--------------------------------------------------------------------------
  63.   # ● 選択肢の最大行数
  64.   #     選択肢を表示するウィンドウの行数の最大数です。
  65.   #     選択肢がこの数より小さければ、選択肢の数に合わせます。
  66.   #--------------------------------------------------------------------------
  67.   RowMax = 4
  68.  
  69.   #--------------------------------------------------------------------------
  70.   # ● 選択肢の位置記憶
  71.   #     前回表示した選択肢と全く同じ内容の選択肢を表示する場合、
  72.   #     カーソルの初期位置を前回選んだ項目にする機能です。
  73.   #     false で無効化できます。
  74.   #--------------------------------------------------------------------------
  75.   Store = true
  76.  
  77.   #--------------------------------------------------------------------------
  78.   # ● 選択肢ヘルプを読み取る文字列
  79.   #--------------------------------------------------------------------------
  80.   Help = "選択肢ヘルプ"
  81.  
  82. end
  83.  
  84. #//////////////////////////////////////////////////////////////////////////////
  85. #
  86. # 以降、変更する必要なし
  87. #
  88. #//////////////////////////////////////////////////////////////////////////////
  89.  
  90.   @material ||= []
  91.   @material << :ChoiceEX
  92.   def self.include?(sym)
  93.     @material.include?(sym)
  94.   end
  95.  
  96. end
  97.  
  98. #==============================================================================
  99. # ■ Game_Message
  100. #------------------------------------------------------------------------------
  101. #  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
  102. # クラスのインスタンスは $game_message で参照されます。
  103. #==============================================================================
  104.  
  105. class Game_Message
  106.   #--------------------------------------------------------------------------
  107.   # ● 公開インスタンス変数
  108.   #--------------------------------------------------------------------------
  109.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  110.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  111.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  112.   attr_accessor :choice_enables           # 選択肢の有効状態
  113.   attr_accessor :choice_help              # 選択肢のヘルプ
  114.   #--------------------------------------------------------------------------
  115.   # ○ クリア
  116.   #--------------------------------------------------------------------------
  117.   alias _wdtk_choice_clear clear
  118.   def clear
  119.     _wdtk_choice_clear
  120.     @choice_x = @choice_y = nil
  121.     @choice_row_max = WdTk::ChoiceEX::RowMax
  122.     @choice_enables = []
  123.     @choice_help = {}
  124.   end
  125. end
  126.  
  127. #==============================================================================
  128. # ■ Game_Interpreter
  129. #==============================================================================
  130. class Game_Interpreter
  131.   #--------------------------------------------------------------------------
  132.   # ☆ 選択肢のセットアップ
  133.   #--------------------------------------------------------------------------
  134.   def setup_choices(params)
  135.     result = []
  136.     add_choices(params, @index, result)
  137.     $game_message.choice_enables = $game_message.choices.collect do |c|
  138.       !c.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
  139.     end
  140.     unless $game_message.choices.empty?
  141.       m = result.index($game_message.choice_cancel_type - 1)
  142.       $game_message.choice_enables << (!m || $game_message.choice_enables[m])
  143.       result << $game_message.choice_cancel_type - 1
  144.       $game_message.choice_proc = Proc.new {|n| @branch[@indent] = result[n] }
  145.     else
  146.       @branch[@indent] = -1
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 選択肢の追加
  151.   #--------------------------------------------------------------------------
  152.   def add_choices(params, i, result, d = 0)
  153.     params[0].each_with_index do |s, n|
  154.       choice = s.dup
  155.       next if choice.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
  156.       $game_message.choices << choice
  157.       result << n + d
  158.     end
  159.     if params[1] == 5 || (params[1] > 0 && result.include?(params[1] + d - 1))
  160.       $game_message.choice_cancel_type = params[1] + d
  161.     end
  162.     indent = @list[i].indent
  163.     loop do
  164.       i += 1
  165.       if @list[i].indent == indent
  166.         case @list[i].code
  167.         when 402 # [**] の場合
  168.           m = result.index(@list[i].parameters[0] + d)
  169.           get_help_texts(m, i + 1) if m
  170.         when 404 # 分岐終了
  171.           break
  172.         end
  173.       end
  174.     end
  175.     i += 1
  176.     add_choices(@list[i].parameters, i, result, d + 5) if @list[i].code == 102
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 分岐用
  180.   #--------------------------------------------------------------------------
  181.   def choice_eval(formula)
  182.     s, v = $game_switches, $game_variables
  183.     begin
  184.       Kernel.eval(formula)
  185.     rescue
  186.       msgbox "以下の条件判定でエラーが出ました。\n\n", formula
  187.       true
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● ヘルプ用テキストの取得
  192.   #--------------------------------------------------------------------------
  193.   def get_help_texts(b, i)
  194.     if @list[i].code == 108 && @list[i].parameters[0] == WdTk::ChoiceEX::Help
  195.       $game_message.choice_help[b] = []
  196.       loop do
  197.         i += 1
  198.         break if @list[i].code != 408
  199.         $game_message.choice_help[b] << @list[i].parameters[0]
  200.       end
  201.     end
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ◯ 注釈
  205.   #--------------------------------------------------------------------------
  206.   alias _wdtk_choice_command_108 command_108
  207.   def command_108
  208.     _wdtk_choice_command_108
  209.     @comments.each do |comment|
  210.       if comment =~ /選択肢位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  211.         $game_message.choice_x = $1.to_i
  212.         $game_message.choice_y = $2.to_i
  213.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  214.       end
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 分岐終了の場合
  219.   #--------------------------------------------------------------------------
  220.   def command_404
  221.     if next_event_code == 102
  222.       @branch[@indent] -= 5 if @branch.include?(@indent)
  223.       @index += 1
  224.       command_skip
  225. #~     else
  226. #~       @branch.delete(@indent)
  227.     end
  228.   end
  229. end
  230.  
  231. #==============================================================================
  232. # ■ Window_ChoiceList
  233. #==============================================================================
  234. class Window_ChoiceList
  235.   #--------------------------------------------------------------------------
  236.   # ☆ 入力処理の開始
  237.   #--------------------------------------------------------------------------
  238.   def start
  239.     return unless close?
  240.     last_choices = @list.collect {|c| c[:name] }
  241.     update_placement
  242.     refresh
  243.     unless WdTk::ChoiceEX::Store && last_choices == $game_message.choices
  244.       select(0)
  245.     end
  246.     open
  247.     activate
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ○ ウィンドウ位置の更新
  251.   #--------------------------------------------------------------------------
  252.   alias _wdtk_choice_update_placement update_placement
  253.   def update_placement
  254.     _wdtk_choice_update_placement
  255.     self.height = [height, fitting_height($game_message.choice_row_max)].min
  256.     if @message_window.y >= Graphics.height / 2
  257.       self.y = @message_window.y - height
  258.     else
  259.       self.y = @message_window.y + @message_window.height
  260.     end
  261.     self.x = $game_message.choice_x if $game_message.choice_x
  262.     self.y = $game_message.choice_y if $game_message.choice_y
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ☆ コマンドリストの作成
  266.   #--------------------------------------------------------------------------
  267.   def make_command_list
  268.     $game_message.choices.each_with_index do |choice, i|
  269.       add_command(choice, :choice, $game_message.choice_enables[i])
  270.     end
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ○ 項目の描画
  274.   #--------------------------------------------------------------------------
  275.   alias _wdtk_choice_draw_item draw_item
  276.   def draw_item(index)
  277.     @choice_enabled = command_enabled?(index)
  278.     _wdtk_choice_draw_item(index)
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● テキスト描画色の変更
  282.   #--------------------------------------------------------------------------
  283.   def change_color(color, enabled = true)
  284.     super(color, enabled && @choice_enabled)
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ● キャンセルボタンが押されたときの処理
  288.   #--------------------------------------------------------------------------
  289.   def process_cancel
  290.     if $game_message.choice_enables[item_max]
  291.       super
  292.     else
  293.       Sound.play_buzzer
  294.     end
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ☆ キャンセルハンドラの呼び出し
  298.   #--------------------------------------------------------------------------
  299.   def call_cancel_handler
  300.     $game_message.choice_proc.call(item_max)
  301.     close
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● ウィンドウを閉じる
  305.   #--------------------------------------------------------------------------
  306.   def close
  307.     @message_window.on_show_fast unless $game_message.choice_help.empty?
  308.     super
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  312.   #--------------------------------------------------------------------------
  313.   def call_update_help
  314.     update_help if active && !$game_message.choice_help.empty?
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● ヘルプウィンドウの更新
  318.   #--------------------------------------------------------------------------
  319.   def update_help
  320.     @message_window.force_clear
  321.     if $game_message.choice_help.include?(index)
  322.       $game_message.texts.replace($game_message.choice_help[index])
  323.     else
  324.       $game_message.texts.clear
  325.     end
  326.   end
  327. end
  328.  
  329. #==============================================================================
  330. # ■ Window_Message
  331. #==============================================================================
  332. class Window_Message
  333.   #--------------------------------------------------------------------------
  334.   # ● 文章の標示を強制クリア
  335.   #--------------------------------------------------------------------------
  336.   def force_clear
  337.     @gold_window.close
  338.     @fiber = nil
  339.     close
  340.     if WdTk.include?(:MesEff)
  341.       @character_sprites.each do |sprite, params|
  342.         next if params.empty?
  343.         sprite.bitmap.clear
  344.         sprite.visible = false
  345.         params.clear
  346.       end
  347.     end
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 文章を最後まで表示する
  351.   #--------------------------------------------------------------------------
  352.   def on_show_fast
  353.     @show_fast = true
  354.   end
  355. end


发脚本用代码框<>工具啊。。。。——VIPArcher留
好大的字!,我以后会注意的!
搜索是一件比发帖容易的事,因此我绝对是搜不到满意答案才来发帖的。

Lv3.寻梦者

梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
帖子
813

开拓者

2
发表于 2015-4-18 01:18:02 | 只看该作者
本帖最后由 jianyulei 于 2015-4-18 01:19 编辑

1的效果直接用软件自带的功能不是更简单?就是开关判定,然后打开了就开始选择,没打开也开始选择,打开的选择里面自己多添加一种选项,也不需要你做两套一直写下去,没打开的所有选择全部用标签的形式引导到打开开关的那个就行了。
如果你是想要很多个选择,觉得软件自带的选项不够,你可以再最后一个选项命名为“其他选择”然后再里面再次开启一个选择条件就可以了。
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
429
在线时间
175 小时
注册时间
2013-11-2
帖子
131
3
 楼主| 发表于 2015-4-18 19:44:28 | 只看该作者
jianyulei 发表于 2015-4-18 01:18
1的效果直接用软件自带的功能不是更简单?就是开关判定,然后打开了就开始选择,没打开也开始选择,打开的 ...

这些办法是可行,可是这要是以大量劳动为代价的。

点评

啊,我知道你说的麻烦的意思了,肯定你不能确定哪些开关会先被打开吧?这样的话数量多了确实超麻烦的……  发表于 2015-4-18 22:05
其實我不太明問題,可否把事件寫法放上来看看  发表于 2015-4-18 20:18
不想学脚本就付出大量劳动呗~  发表于 2015-4-18 20:10
搜索是一件比发帖容易的事,因此我绝对是搜不到满意答案才来发帖的。
回复 支持 1 反对 0

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-20 05:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表