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

Project1

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

[已经解决] 怎么让开关变量条件控制事件选项的出现

[复制链接]

Lv2.观梦者

梦石
0
星屑
479
在线时间
35 小时
注册时间
2019-8-22
帖子
48
跳转到指定楼层
1
发表于 2020-1-29 20:21:28 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 VIPArcher 于 2022-6-10 16:18 编辑

就是如果事件是这样子的,打电话式的,我想让玩家选择后没有这个选项,应该如何设置?就是如果玩家选择了110,然后再次调查时,就变成没有110这个选项了,我尝试过用独立开关,但是好像不行(因为独立开关只有4个,然后用开关的话,太乱了,很难记住,而且要设置很多事件),就是如果玩家直接选择了120,那么怎么样让接下来没有120?(这个可以实现)然后接下来只剩下了110和陌生的号码,如果直接选择了陌生的号码,怎么才可以让它接下来只有110
总的来说,就是该怎么样才可以自动判断玩家选择了什么选项,然后呈现出不同的内容?
谢谢各位了!

1.png (31.49 KB, 下载次数: 5)

1.png

2.png (25.45 KB, 下载次数: 7)

2.png

Lv2.观梦者

梦石
0
星屑
479
在线时间
35 小时
注册时间
2019-8-22
帖子
48
2
 楼主| 发表于 2020-1-29 20:23:49 | 只看该作者
我···我点错了!请各位不要在意这个售价
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2560
在线时间
447 小时
注册时间
2019-6-22
帖子
74
3
发表于 2020-1-29 20:26:43 | 只看该作者
本帖最后由 kunikai 于 2020-1-29 20:49 编辑

把下方脚本插入到默认脚本以下,Main以上。脚本原作者为“木星ペンギン”。

在某选项中写“要显示的文字 if(s[88])”,则当88号开关打开时才显示该选项。
更多使用方法参见脚本注释。

顺带一提,请善用“搜索”功能。

下面是一楼事件的简单例子。


RUBY 代码复制
  1. =begin
  2.  
  3. ▼ 选项拓展 ver. 3.4
  4.  
  5. 仅用于 RPG Maker 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.  
  29. □ 如果在选项中填入 if(条件) 、且不满足条件时,该选项会被隐藏。
  30.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  31.   ?s 代表开关、v 代表变量。
  32.  
  33.   例子:
  34.   if(s[1]&&s[2])
  35.  
  36.   if(v[1]==1)
  37.  
  38.   ?如果「取消的时候」的选项因为不符合显示条件而被隐藏,则用“无效”作为代替。
  39.  
  40. □ 在注释中填入以下字符串,指定某变量的值为指针的初始位置。
  41.  
  42.     记忆指针(n)
  43.    
  44.       n : 指针初始位置的变量
  45.  
  46.   ?每当选项的指针位置改变时,选项位置的数字会被存储于变量中。
  47.  
  48. □ 在注释中填入以下字符串,暂时改变选项的显示位置。
  49.  
  50.     选项位置(x, y[, row])
  51.    
  52.       x   : 选项窗口的x坐标。
  53.       y   : 选项窗口的y坐标。
  54.       row : 选项最大行数。
  55.             未设定时,会显示全部的选项。
  56.  
  57. □ 在注释中填入以下字符串,使选项显示在对话框的背后。
  58.     请在[显示文字]后面使用。
  59.  
  60.     选项位置(对话框后)
  61.    
  62. □ 在注释中填入以下字符串,则隐藏选项窗口的背景。
  63.  
  64.     背景OFF
  65.    
  66. □ 在选项中填入 en(条件) 、当不符合条件时,选项会变半透明。
  67.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  68.   ?s[n] 代表条件是开启n号开关、v[n] 代表n号变量。
  69.  
  70.   例子:
  71.   en(s[1]&&s[2])
  72.  
  73.   en(v[1]==1)
  74.  
  75.   ?如果「取消的时候」的选项因为不符合显示条件而变半透明,则会播放蜂鸣声。
  76.  
  77. □ 各选项之下的注释中填入以下字符串,当移动到各选项中时,会显示选项的帮助文字。
  78.  
  79.     选项帮助
  80.      (内容)
  81.     
  82.      例如:
  83.     
  84.      选项帮助
  85.      可以住宿。
  86.    
  87. □ 请在以下网址中查看详细介绍。
  88.  
  89.   [url]http://woodpenguin.web.fc2.com/rgss3/choice_ex.html[/url]
  90.  
  91. =end
  92. module WdTk
  93. module ChoiceEX
  94. #//////////////////////////////////////////////////////////////////////////////
  95. #
  96. # 设定部分
  97. #
  98. #//////////////////////////////////////////////////////////////////////////////
  99.   #--------------------------------------------------------------------------
  100.   # ● 选项最大行数
  101.   #     如果选项数小于这个数字。
  102.   #     则选项最大数与选项数相同。
  103.   #--------------------------------------------------------------------------
  104.   RowMax = 4
  105.  
  106.   #--------------------------------------------------------------------------
  107.   # ● 读取选项帮助的开头文字
  108.   #--------------------------------------------------------------------------
  109.   Help = "选项帮助"
  110.  
  111. end
  112.  
  113. #//////////////////////////////////////////////////////////////////////////////
  114. #
  115. # 以下部分、没有修改的必要
  116. #
  117. #//////////////////////////////////////////////////////////////////////////////
  118.  
  119.   @material ||= []
  120.   @material << :ChoiceEX
  121.   def self.include?(sym)
  122.     @material.include?(sym)
  123.   end
  124.  
  125. end
  126.  
  127. #==============================================================================
  128. # ■ Game_Message
  129. #==============================================================================
  130. class Game_Message
  131.   #--------------------------------------------------------------------------
  132.   # ● 公開インスタンス変数
  133.   #--------------------------------------------------------------------------
  134.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  135.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  136.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  137.   attr_accessor :choice_help              # 選択肢のヘルプ
  138.   attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  139.   attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  140.   attr_accessor :under_choice             # 選択肢をメッセージの下に表示
  141.   #--------------------------------------------------------------------------
  142.   # ○ クリア
  143.   #--------------------------------------------------------------------------
  144.   alias _wdtk_choice_clear clear
  145.   def clear
  146.     _wdtk_choice_clear
  147.     @choice_x = @choice_y = nil
  148.     @choice_row_max = WdTk::ChoiceEX::RowMax
  149.     @choice_help = {}
  150.     @choice_var_id = 0
  151.     @choice_background = 0
  152.     @under_choice = false
  153.   end
  154. end
  155.  
  156. #==============================================================================
  157. # ■ Game_Interpreter
  158. #==============================================================================
  159. class Game_Interpreter
  160.   #--------------------------------------------------------------------------
  161.   # ☆ 選択肢のセットアップ
  162.   #--------------------------------------------------------------------------
  163.   def setup_choices(params)
  164.     add_choices(params, @index)
  165.     $game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 選択肢の追加
  169.   #--------------------------------------------------------------------------
  170.   def add_choices(params, i, d = 0)
  171.     params[0].each_with_index {|s, n| $game_message.choices[n + d] = s }
  172.     $game_message.choice_cancel_type = params[1] + d if params[1] > 0
  173.     indent = @list[i].indent
  174.     loop do
  175.       i += 1
  176.       if @list[i].indent == indent
  177.         case @list[i].code
  178.         when 402 # [**] の場合
  179.           get_help_texts(@list[i].parameters[0] + d, i + 1)
  180.         when 404 # 分岐終了
  181.           break
  182.         end
  183.       end
  184.     end
  185.     i += 1
  186.     add_choices(@list[i].parameters, i, d + 5) if @list[i].code == 102
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● ヘルプ用テキストの取得
  190.   #--------------------------------------------------------------------------
  191.   def get_help_texts(b, i)
  192.     if @list[i].code == 108 && @list[i].parameters[0] == WdTk::ChoiceEX::Help
  193.       $game_message.choice_help[b] = []
  194.       while @list[i + 1].code == 408
  195.         i += 1
  196.         $game_message.choice_help[b] << @list[i].parameters[0]
  197.       end
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ? 注釈
  202.   #--------------------------------------------------------------------------
  203.   alias _wdtk_choice_command_108 command_108
  204.   def command_108
  205.     _wdtk_choice_command_108
  206.     @comments.each do |comment|
  207.       case comment
  208.       when /选项位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  209.         $game_message.choice_x = $1.to_i
  210.         $game_message.choice_y = $2.to_i
  211.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  212.       when "选项位置(对话框后)"
  213.         $game_message.under_choice = true
  214.         $game_message.choice_background = 1
  215.       when /记忆指针\((\d+)\)/
  216.         $game_message.choice_var_id = $1.to_i
  217.       when /背景(ON|OFF)/
  218.         $game_message.choice_background = ($1 == "ON" ? 0 : 1)
  219.       end
  220.     end
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ☆ 分岐終了の場合
  224.   #--------------------------------------------------------------------------
  225.   def command_404
  226.     if next_event_code == 102
  227.       @branch[@indent] -= 5 if @branch.include?(@indent)
  228.       @index += 1
  229.       command_skip
  230.     end
  231.   end
  232. end
  233.  
  234. #==============================================================================
  235. # ■ Window_ChoiceList
  236. #==============================================================================
  237. class Window_ChoiceList
  238.   #--------------------------------------------------------------------------
  239.   # ☆ 入力処理の開始
  240.   #--------------------------------------------------------------------------
  241.   def start
  242.     return unless close?
  243.     clear_command_list
  244.     make_command_list
  245.     if @list.empty?
  246.       $game_message.choice_proc.call(-1)
  247.       return
  248.     end
  249.     update_placement
  250.     refresh
  251.     select(0)
  252.     if $game_message.choice_var_id > 0
  253.       select_ext($game_variables[$game_message.choice_var_id])
  254.     end
  255.     open
  256.     activate
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ☆ ウィンドウ位置の更新
  260.   #--------------------------------------------------------------------------
  261.   def update_placement
  262.     self.width = [max_choice_width + 12, 96].max + padding * 2
  263.     self.width = [width, Graphics.width].min
  264.     n = [@list.size, $game_message.choice_row_max].min
  265.     self.height = fitting_height(n)
  266.     self.x = Graphics.width - width
  267.     if @message_window.y >= Graphics.height / 2
  268.       self.y = @message_window.y - height
  269.     else
  270.       self.y = @message_window.y + @message_window.height
  271.     end
  272.     self.x = $game_message.choice_x if $game_message.choice_x
  273.     self.y = $game_message.choice_y if $game_message.choice_y
  274.     self.z = $game_message.under_choice ? 210 : 100
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ☆ 選択肢の最大幅を取得
  278.   #--------------------------------------------------------------------------
  279.   def max_choice_width
  280.     @list.collect {|com| text_size(com[:name]).width }.max || 0
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ☆ コマンドリストの作成
  284.   #--------------------------------------------------------------------------
  285.   def make_command_list
  286.     $game_message.choices.each_with_index do |choice, i|
  287.       next unless choice
  288.       str = choice.dup
  289.       next if str.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
  290.       enable = !str.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
  291.       add_command(str, :choice, enable, i)
  292.     end
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ○ 項目の描画
  296.   #--------------------------------------------------------------------------
  297.   alias _wdtk_choice_draw_item draw_item
  298.   def draw_item(index)
  299.     @choice_enabled = command_enabled?(index)
  300.     _wdtk_choice_draw_item(index)
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● テキスト描画色の変更
  304.   #--------------------------------------------------------------------------
  305.   def change_color(color, enabled = true)
  306.     super(color, enabled && @choice_enabled)
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ☆ 決定ハンドラの呼び出し
  310.   #--------------------------------------------------------------------------
  311.   def call_ok_handler
  312.     $game_message.choice_proc.call(current_ext)
  313.     close
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● キャンセルボタンが押されたときの処理
  317.   #--------------------------------------------------------------------------
  318.   def process_cancel
  319.     return super if $game_message.choice_cancel_type % 5 == 0
  320.     index = @list.index {|c| c[:ext] == $game_message.choice_cancel_type - 1 }
  321.     return unless index
  322.     return super if command_enabled?(index)
  323.     Sound.play_buzzer
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● ウィンドウを閉じる
  327.   #--------------------------------------------------------------------------
  328.   def close
  329.     @message_window.on_show_fast unless $game_message.choice_help.empty?
  330.     super
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  334.   #--------------------------------------------------------------------------
  335.   def call_update_help
  336.     update_help if active && !$game_message.choice_help.empty?
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● ヘルプウィンドウの更新
  340.   #--------------------------------------------------------------------------
  341.   def update_help
  342.     @message_window.force_clear
  343.     if $game_message.choice_help.include?(current_ext)
  344.       $game_message.texts.replace($game_message.choice_help[current_ext])
  345.     else
  346.       $game_message.texts.clear
  347.     end
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 分岐用
  351.   #--------------------------------------------------------------------------
  352.   def choice_eval(formula)
  353.     s, v = $game_switches, $game_variables
  354.     begin
  355.       Kernel.eval(formula)
  356.     rescue
  357.       msgbox "以下条件判断发生错误。\n\n", formula
  358.       true
  359.     end
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # ● フレーム更新
  363.   #--------------------------------------------------------------------------
  364.   def update
  365.     last_index = @index
  366.     super
  367.     if last_index != @index && $game_message.choice_var_id > 0
  368.       $game_variables[$game_message.choice_var_id] = current_ext
  369.     end
  370.   end
  371. end
  372.  
  373. #==============================================================================
  374. # ■ Window_Message
  375. #==============================================================================
  376. class Window_Message
  377.   #--------------------------------------------------------------------------
  378.   # ○ ウィンドウ背景の更新
  379.   #--------------------------------------------------------------------------
  380.   alias _wdtk_choice_update_background update_background
  381.   def update_background
  382.     _wdtk_choice_update_background
  383.     @choice_window.opacity = $game_message.choice_background == 0 ? 255 : 0
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ○ ウィンドウ位置の更新
  387.   #--------------------------------------------------------------------------
  388.   alias _wdtk_choice_update_placement update_placement
  389.   def update_placement
  390.     _wdtk_choice_update_placement
  391.     reset_under_choice
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ○ 改行文字の処理
  395.   #--------------------------------------------------------------------------
  396.   alias _wdtk_choice_process_new_line process_new_line
  397.   def process_new_line(text, pos)
  398.     if $game_message.under_choice
  399.       $game_message.choice_y += pos[:height]
  400.       ch = self.contents_height + self.y - $game_message.choice_y
  401.       $game_message.choice_row_max = ch / line_height
  402.     end
  403.     _wdtk_choice_process_new_line(text, pos)
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ○ 改ページ処理
  407.   #--------------------------------------------------------------------------
  408.   alias _wdtk_choice_new_page new_page
  409.   def new_page(text, pos)
  410.     _wdtk_choice_new_page(text, pos)
  411.     reset_under_choice
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ● 選択肢をメッセージ下に表示する際のリセット
  415.   #--------------------------------------------------------------------------
  416.   def reset_under_choice
  417.     if $game_message.under_choice
  418.       $game_message.choice_x = self.x + 16 + new_line_x
  419.       $game_message.choice_y = self.y
  420.       $game_message.choice_row_max = visible_line_number
  421.     end
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # ● 文章の標示を強制クリア
  425.   #--------------------------------------------------------------------------
  426.   def force_clear
  427.     @gold_window.close
  428.     @fiber = nil
  429.     close
  430.     if WdTk.include?(:MesEff)
  431.       @character_sprites.each do |sprite, params|
  432.         next if params.empty?
  433.         sprite.bitmap.clear
  434.         sprite.visible = false
  435.         params.clear
  436.       end
  437.     end
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ● 文章を最後まで表示する
  441.   #--------------------------------------------------------------------------
  442.   def on_show_fast
  443.     @show_fast = true
  444.   end
  445. end

评分

参与人数 1星屑 +100 收起 理由
VIPArcher + 100 认可答案

查看全部评分

一介凡人。对大多数事情都有心无力的凡人。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 13:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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