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

Project1

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

[已经解决] 萌新问下有没有可能用开关来操纵选项

[复制链接]

Lv2.观梦者

梦石
0
星屑
725
在线时间
97 小时
注册时间
2019-9-17
帖子
7
跳转到指定楼层
1
发表于 2019-10-4 22:04:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
例如:开启X开关时选项在A和B中增加选项C。由于文本量过于巨大,我不打算用分支事件一个一个做,请问有没有脚本可以完成这项作业?

Lv3.寻梦者

梦石
0
星屑
1616
在线时间
149 小时
注册时间
2018-12-27
帖子
324
2
发表于 2019-10-4 22:56:50 | 只看该作者
脚本插入过多的结果就是容易崩溃和冲突,最好使用变量。就这样。
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
13763
在线时间
5691 小时
注册时间
2011-7-18
帖子
158

开拓者

3
发表于 2019-10-4 23:33:19 | 只看该作者
本帖最后由 gqxastg 于 2019-10-5 14:27 编辑

推荐 木星ペンギン 的 選択肢拡張
脚本

插入后直接在显示选项里这么写
显示的文字 if(s[1])

就是只有1号开关打开时才显示该选项
把if换成en的话就是1号开关打开时候才能选择该选项,否则会半透明显示且无法选择

楼下给出汉化版带使用例了
我刚从作者官网把最新版3.5扒过来了 新修正了转义符导致的选项宽度获取错误

评分

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

查看全部评分

这里岚风·雷,任饭、PM理性粉、UT/DR原作粉、(Trans)Furry自萌,半吊子技术一枚_(:з」∠)_    游戏制作交流工(liao)作(tian)室欢迎来玩!
【无偿/有偿】RGSS3(VA)脚本定制 + 合作招募/同好交友    修正Firefox/火狐浏览器的代码框复制问题(油猴脚本)
Click→←Click
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
1
星屑
14504
在线时间
2086 小时
注册时间
2017-9-28
帖子
662
4
发表于 2019-10-5 13:11:14 | 只看该作者
  1. =begin

  2. ▼ 选项拓展 ver. 3.4

  3. 仅用于 RPG Maker VXAce

  4. 制作 : 木星ペンギン
  5. URL  : http://woodpenguin.blog.fc2.com/

  6. ------------------------------------------------------------------------------
  7. 概要

  8.     添加功能:
  9. □ 合并两个连续选项为一个大选项。
  10. □ 选项显示条件功能,不符合显示条件的选项会被隐藏。
  11. □ 设定选项和指针的初始位置
  12.     当前指针的位置可以赋值于变量。

  13. □ 临时更改选项窗口的位置。
  14. □ 设定选项条件,不符合条件时,选项变成半透明且不可被选择。
  15. □ 各个选项都可以有相应的帮助信息。

  16. ------------------------------------------------------------------------------
  17. 使用方法

  18. □ 当两个选项连续排列时,它们会被合并为一个选项。
  19.   ? 合并后选项的「取消的时候」为最后一个选项的设定。
  20.   
  21. □ 如果在选项中填入 if(条件) 、且不满足条件时,该选项会被隐藏。
  22.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  23.   ?s 代表开关、v 代表变量。
  24.   
  25.   例子:
  26.   if(s[1]&&s[2])
  27.   
  28.   if(v[1]==1)
  29.   
  30.   ?如果「取消的时候」的选项因为不符合显示条件而被隐藏,则用“无效”作为代替。
  31.   
  32. □ 在注释中填入以下字符串,指定某变量的值为指针的初始位置。
  33.   
  34.     记忆指针(n)
  35.    
  36.       n : 指针初始位置的变量
  37.   
  38.   ?每当选项的指针位置改变时,选项位置的数字会被存储于变量中。
  39.   
  40. □ 在注释中填入以下字符串,暂时改变选项的显示位置。
  41.   
  42.     选项位置(x, y[, row])
  43.    
  44.       x   : 选项窗口的x坐标。
  45.       y   : 选项窗口的y坐标。
  46.       row : 选项最大行数。
  47.             未设定时,会显示全部的选项。
  48.   
  49. □ 在注释中填入以下字符串,使选项显示在对话框的背后。
  50.     请在[显示文字]后面使用。
  51.   
  52.     选项位置(对话框后)
  53.    
  54. □ 在注释中填入以下字符串,则隐藏选项窗口的背景。
  55.   
  56.     背景OFF
  57.    
  58. □ 在选项中填入 en(条件) 、当不符合条件时,选项会变半透明。
  59.   ?条件用 eval 进行判断。(详细参考【内建功能】)
  60.   ?s[n] 代表条件是开启n号开关、v[n] 代表n号变量。
  61.   
  62.   例子:
  63.   en(s[1]&&s[2])
  64.   
  65.   en(v[1]==1)
  66.   
  67.   ?如果「取消的时候」的选项因为不符合显示条件而变半透明,则会播放蜂鸣声。
  68.   
  69. □ 各选项之下的注释中填入以下字符串,当移动到各选项中时,会显示选项的帮助文字。
  70.   
  71.     选项帮助
  72.      (内容)
  73.      
  74.      例如:
  75.      
  76.      选项帮助
  77.      可以住宿。
  78.    
  79. □ 请在以下网址中查看详细介绍。

  80.   http://woodpenguin.web.fc2.com/rgss3/choice_ex.html
  81.   
  82. =end
  83. module WdTk
  84. module ChoiceEX
  85. #//////////////////////////////////////////////////////////////////////////////
  86. #
  87. # 设定部分
  88. #
  89. #//////////////////////////////////////////////////////////////////////////////
  90.   #--------------------------------------------------------------------------
  91.   # ● 选项最大行数
  92.   #     如果选项数小于这个数字。
  93.   #     则选项最大数与选项数相同。
  94.   #--------------------------------------------------------------------------
  95.   RowMax = 4
  96.   
  97.   #--------------------------------------------------------------------------
  98.   # ● 读取选项帮助的开头文字
  99.   #--------------------------------------------------------------------------
  100.   Help = "选项帮助"
  101.   
  102. end

  103. #//////////////////////////////////////////////////////////////////////////////
  104. #
  105. # 以下部分、没有修改的必要
  106. #
  107. #//////////////////////////////////////////////////////////////////////////////

  108.   @material ||= []
  109.   @material << :ChoiceEX
  110.   def self.include?(sym)
  111.     @material.include?(sym)
  112.   end
  113.   
  114. end

  115. #==============================================================================
  116. # ■ Game_Message
  117. #==============================================================================
  118. class Game_Message
  119.   #--------------------------------------------------------------------------
  120.   # ● 公開インスタンス変数
  121.   #--------------------------------------------------------------------------
  122.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  123.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  124.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  125.   attr_accessor :choice_help              # 選択肢のヘルプ
  126.   attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  127.   attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  128.   attr_accessor :under_choice             # 選択肢をメッセージの下に表示
  129.   #--------------------------------------------------------------------------
  130.   # ○ クリア
  131.   #--------------------------------------------------------------------------
  132.   alias _wdtk_choice_clear clear
  133.   def clear
  134.     _wdtk_choice_clear
  135.     @choice_x = @choice_y = nil
  136.     @choice_row_max = WdTk::ChoiceEX::RowMax
  137.     @choice_help = {}
  138.     @choice_var_id = 0
  139.     @choice_background = 0
  140.     @under_choice = false
  141.   end
  142. end

  143. #==============================================================================
  144. # ■ Game_Interpreter
  145. #==============================================================================
  146. class Game_Interpreter
  147.   #--------------------------------------------------------------------------
  148.   # ☆ 選択肢のセットアップ
  149.   #--------------------------------------------------------------------------
  150.   def setup_choices(params)
  151.     add_choices(params, @index)
  152.     $game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 選択肢の追加
  156.   #--------------------------------------------------------------------------
  157.   def add_choices(params, i, d = 0)
  158.     params[0].each_with_index {|s, n| $game_message.choices[n + d] = s }
  159.     $game_message.choice_cancel_type = params[1] + d if params[1] > 0
  160.     indent = @list[i].indent
  161.     loop do
  162.       i += 1
  163.       if @list[i].indent == indent
  164.         case @list[i].code
  165.         when 402 # [**] の場合
  166.           get_help_texts(@list[i].parameters[0] + d, i + 1)
  167.         when 404 # 分岐終了
  168.           break
  169.         end
  170.       end
  171.     end
  172.     i += 1
  173.     add_choices(@list[i].parameters, i, d + 5) if @list[i].code == 102
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● ヘルプ用テキストの取得
  177.   #--------------------------------------------------------------------------
  178.   def get_help_texts(b, i)
  179.     if @list[i].code == 108 && @list[i].parameters[0] == WdTk::ChoiceEX::Help
  180.       $game_message.choice_help[b] = []
  181.       while @list[i + 1].code == 408
  182.         i += 1
  183.         $game_message.choice_help[b] << @list[i].parameters[0]
  184.       end
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ? 注釈
  189.   #--------------------------------------------------------------------------
  190.   alias _wdtk_choice_command_108 command_108
  191.   def command_108
  192.     _wdtk_choice_command_108
  193.     @comments.each do |comment|
  194.       case comment
  195.       when /选项位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  196.         $game_message.choice_x = $1.to_i
  197.         $game_message.choice_y = $2.to_i
  198.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  199.       when "选项位置(对话框后)"
  200.         $game_message.under_choice = true
  201.         $game_message.choice_background = 1
  202.       when /记忆指针\((\d+)\)/
  203.         $game_message.choice_var_id = $1.to_i
  204.       when /背景(ON|OFF)/
  205.         $game_message.choice_background = ($1 == "ON" ? 0 : 1)
  206.       end
  207.     end
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ☆ 分岐終了の場合
  211.   #--------------------------------------------------------------------------
  212.   def command_404
  213.     if next_event_code == 102
  214.       @branch[@indent] -= 5 if @branch.include?(@indent)
  215.       @index += 1
  216.       command_skip
  217.     end
  218.   end
  219. end

  220. #==============================================================================
  221. # ■ Window_ChoiceList
  222. #==============================================================================
  223. class Window_ChoiceList
  224.   #--------------------------------------------------------------------------
  225.   # ☆ 入力処理の開始
  226.   #--------------------------------------------------------------------------
  227.   def start
  228.     return unless close?
  229.     clear_command_list
  230.     make_command_list
  231.     if @list.empty?
  232.       $game_message.choice_proc.call(-1)
  233.       return
  234.     end
  235.     update_placement
  236.     refresh
  237.     select(0)
  238.     if $game_message.choice_var_id > 0
  239.       select_ext($game_variables[$game_message.choice_var_id])
  240.     end
  241.     open
  242.     activate
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ☆ ウィンドウ位置の更新
  246.   #--------------------------------------------------------------------------
  247.   def update_placement
  248.     self.width = [max_choice_width + 12, 96].max + padding * 2
  249.     self.width = [width, Graphics.width].min
  250.     n = [@list.size, $game_message.choice_row_max].min
  251.     self.height = fitting_height(n)
  252.     self.x = Graphics.width - width
  253.     if @message_window.y >= Graphics.height / 2
  254.       self.y = @message_window.y - height
  255.     else
  256.       self.y = @message_window.y + @message_window.height
  257.     end
  258.     self.x = $game_message.choice_x if $game_message.choice_x
  259.     self.y = $game_message.choice_y if $game_message.choice_y
  260.     self.z = $game_message.under_choice ? 210 : 100
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ☆ 選択肢の最大幅を取得
  264.   #--------------------------------------------------------------------------
  265.   def max_choice_width
  266.     @list.collect {|com| text_size(com[:name]).width }.max || 0
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ☆ コマンドリストの作成
  270.   #--------------------------------------------------------------------------
  271.   def make_command_list
  272.     $game_message.choices.each_with_index do |choice, i|
  273.       next unless choice
  274.       str = choice.dup
  275.       next if str.slice!(/\s*if\(([^\)]+)\)/i) && !choice_eval($1)
  276.       enable = !str.slice!(/\s*en\(([^\)]+)\)/i) || choice_eval($1)
  277.       add_command(str, :choice, enable, i)
  278.     end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ○ 項目の描画
  282.   #--------------------------------------------------------------------------
  283.   alias _wdtk_choice_draw_item draw_item
  284.   def draw_item(index)
  285.     @choice_enabled = command_enabled?(index)
  286.     _wdtk_choice_draw_item(index)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● テキスト描画色の変更
  290.   #--------------------------------------------------------------------------
  291.   def change_color(color, enabled = true)
  292.     super(color, enabled && @choice_enabled)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ☆ 決定ハンドラの呼び出し
  296.   #--------------------------------------------------------------------------
  297.   def call_ok_handler
  298.     $game_message.choice_proc.call(current_ext)
  299.     close
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● キャンセルボタンが押されたときの処理
  303.   #--------------------------------------------------------------------------
  304.   def process_cancel
  305.     return super if $game_message.choice_cancel_type % 5 == 0
  306.     index = @list.index {|c| c[:ext] == $game_message.choice_cancel_type - 1 }
  307.     return unless index
  308.     return super if command_enabled?(index)
  309.     Sound.play_buzzer
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ● ウィンドウを閉じる
  313.   #--------------------------------------------------------------------------
  314.   def close
  315.     @message_window.on_show_fast unless $game_message.choice_help.empty?
  316.     super
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  320.   #--------------------------------------------------------------------------
  321.   def call_update_help
  322.     update_help if active && !$game_message.choice_help.empty?
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● ヘルプウィンドウの更新
  326.   #--------------------------------------------------------------------------
  327.   def update_help
  328.     @message_window.force_clear
  329.     if $game_message.choice_help.include?(current_ext)
  330.       $game_message.texts.replace($game_message.choice_help[current_ext])
  331.     else
  332.       $game_message.texts.clear
  333.     end
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 分岐用
  337.   #--------------------------------------------------------------------------
  338.   def choice_eval(formula)
  339.     s, v = $game_switches, $game_variables
  340.     begin
  341.       Kernel.eval(formula)
  342.     rescue
  343.       msgbox "以下条件判断发生错误。\n\n", formula
  344.       true
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● フレーム更新
  349.   #--------------------------------------------------------------------------
  350.   def update
  351.     last_index = @index
  352.     super
  353.     if last_index != @index && $game_message.choice_var_id > 0
  354.       $game_variables[$game_message.choice_var_id] = current_ext
  355.     end
  356.   end
  357. end

  358. #==============================================================================
  359. # ■ Window_Message
  360. #==============================================================================
  361. class Window_Message
  362.   #--------------------------------------------------------------------------
  363.   # ○ ウィンドウ背景の更新
  364.   #--------------------------------------------------------------------------
  365.   alias _wdtk_choice_update_background update_background
  366.   def update_background
  367.     _wdtk_choice_update_background
  368.     @choice_window.opacity = $game_message.choice_background == 0 ? 255 : 0
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ○ ウィンドウ位置の更新
  372.   #--------------------------------------------------------------------------
  373.   alias _wdtk_choice_update_placement update_placement
  374.   def update_placement
  375.     _wdtk_choice_update_placement
  376.     reset_under_choice
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ○ 改行文字の処理
  380.   #--------------------------------------------------------------------------
  381.   alias _wdtk_choice_process_new_line process_new_line
  382.   def process_new_line(text, pos)
  383.     if $game_message.under_choice
  384.       $game_message.choice_y += pos[:height]
  385.       ch = self.contents_height + self.y - $game_message.choice_y
  386.       $game_message.choice_row_max = ch / line_height
  387.     end
  388.     _wdtk_choice_process_new_line(text, pos)
  389.   end
  390.   #--------------------------------------------------------------------------
  391.   # ○ 改ページ処理
  392.   #--------------------------------------------------------------------------
  393.   alias _wdtk_choice_new_page new_page
  394.   def new_page(text, pos)
  395.     _wdtk_choice_new_page(text, pos)
  396.     reset_under_choice
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 選択肢をメッセージ下に表示する際のリセット
  400.   #--------------------------------------------------------------------------
  401.   def reset_under_choice
  402.     if $game_message.under_choice
  403.       $game_message.choice_x = self.x + 16 + new_line_x
  404.       $game_message.choice_y = self.y
  405.       $game_message.choice_row_max = visible_line_number
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 文章の標示を強制クリア
  410.   #--------------------------------------------------------------------------
  411.   def force_clear
  412.     @gold_window.close
  413.     @fiber = nil
  414.     close
  415.     if WdTk.include?(:MesEff)
  416.       @character_sprites.each do |sprite, params|
  417.         next if params.empty?
  418.         sprite.bitmap.clear
  419.         sprite.visible = false
  420.         params.clear
  421.       end
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 文章を最後まで表示する
  426.   #--------------------------------------------------------------------------
  427.   def on_show_fast
  428.     @show_fast = true
  429.   end
  430. end
复制代码
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
725
在线时间
97 小时
注册时间
2019-9-17
帖子
7
5
 楼主| 发表于 2019-10-5 22:02:00 | 只看该作者
gqxastg 发表于 2019-10-4 23:33
推荐 木星ペンギン 的 選択肢拡張
[fold=脚本]=begin

谢谢dalao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 11:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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