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

Project1

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

[已经解决] 關於選項問題…

[复制链接]

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
跳转到指定楼层
1
发表于 2021-10-17 17:06:42 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 黑雪哲也 于 2021-10-24 14:18 编辑

關於選項問題,這是之前老早某些好心網友幫回答的腳本。

這個→https://rpg.blue/thread-396738-1-1.html

然後現在重用不知道為何發生了這個問題。




求解答,感謝。

  1. =begin

  2. ▼ 選択肢拡張 ver. 3.2

  3. RPGツクール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.     カーソルの初期位置になります。
  27.   
  28.     カーソル記憶(n)
  29.    
  30.       n : カーソル初期位置の入った変数番号
  31.   
  32.   ・選択肢のカーソルの位置が変更されるたびに、
  33.     この変数に選択肢の番号が入れられるようになります。
  34.   
  35. □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの表示位置を
  36.    一時的に変更することが出来ます。
  37.   
  38.     選択肢位置(x, y[, row])
  39.    
  40.       x   : ウィンドウを表示する X 座標。
  41.       y   : ウィンドウを表示する Y 座標。
  42.       row : 選択肢を表示する最大行数。
  43.             指定しない場合は、通常の最大行数を無視して
  44.             すべての選択肢が表示されます。
  45.   
  46. □ 注釈に以下の文字列を入れることで、選択肢ウィンドウの背景が非表示になります。
  47.   
  48.     背景OFF
  49.    
  50. □ 選択肢の文章中に en(条件) と入れ、その条件が偽になると項目が半透明で表示されます。
  51.   ・条件は eval によって評価されます。(詳細は【組み込み関数】を参照)
  52.   ・s でスイッチ、v で変数を参照できます。
  53.   ・「キャンセルの場合」の項目が半透明の場合、ブザーが鳴ります。
  54.   
  55. □ 各項目の下に、注釈で以下の文字列を入れると、続きの注釈を
  56.     項目のヘルプメッセージとしてカーソルを合わせたときに標示することができます。
  57.   
  58.     選択肢ヘルプ
  59.    
  60. □ 詳細は下記のサイトを参照してください。

  61.   http://woodpenguin.web.fc2.com/rgss3/choice_ex.html
  62.   
  63. =end
  64. module WdTk
  65. module ChoiceEX
  66. #//////////////////////////////////////////////////////////////////////////////
  67. #
  68. # 設定項目
  69. #
  70. #//////////////////////////////////////////////////////////////////////////////
  71.   #--------------------------------------------------------------------------
  72.   # ● 選択肢の最大行数
  73.   #     選択肢を表示するウィンドウの行数の最大数です。
  74.   #     選択肢がこの数より小さければ、選択肢の数に合わせます。
  75.   #--------------------------------------------------------------------------
  76.   RowMax = 4
  77.   
  78.   #--------------------------------------------------------------------------
  79.   # ● 選択肢ヘルプを読み取る文字列
  80.   #--------------------------------------------------------------------------
  81.   Help = "選択肢ヘルプ"
  82.   
  83. end

  84. #//////////////////////////////////////////////////////////////////////////////
  85. #
  86. # 以降、変更する必要なし
  87. #
  88. #//////////////////////////////////////////////////////////////////////////////

  89.   @material ||= []
  90.   @material << :ChoiceEX
  91.   def self.include?(sym)
  92.     @material.include?(sym)
  93.   end
  94.   
  95. end

  96. #==============================================================================
  97. # ■ Game_Message
  98. #==============================================================================
  99. class Game_Message
  100.   #--------------------------------------------------------------------------
  101.   # ● 公開インスタンス変数
  102.   #--------------------------------------------------------------------------
  103.   attr_accessor :choice_x                 # 選択肢ウィンドウの表示 X 座標
  104.   attr_accessor :choice_y                 # 選択肢ウィンドウの表示 Y 座標
  105.   attr_accessor :choice_row_max           # 選択肢ウィンドウの表示行数
  106.   attr_accessor :choice_help              # 選択肢のヘルプ
  107.   attr_accessor :choice_var_id            # 選択肢のカーソル位置を入れる変数ID
  108.   attr_accessor :choice_background        # 選択肢ウィンドウ背景の表示状態
  109.   #--------------------------------------------------------------------------
  110.   # ○ クリア
  111.   #--------------------------------------------------------------------------
  112.   alias _wdtk_choice_clear clear
  113.   def clear
  114.     _wdtk_choice_clear
  115.     @choice_x = @choice_y = nil
  116.     @choice_row_max = WdTk::ChoiceEX::RowMax
  117.     @choice_help = {}
  118.     @choice_var_id = 0
  119.     @choice_background = 0
  120.   end
  121. end

  122. #==============================================================================
  123. # ■ Game_Interpreter
  124. #==============================================================================
  125. class Game_Interpreter
  126.   #--------------------------------------------------------------------------
  127.   # ☆ 選択肢のセットアップ
  128.   #--------------------------------------------------------------------------
  129.   def setup_choices(params)
  130.     add_choices(params, @index)
  131.     $game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 選択肢の追加
  135.   #--------------------------------------------------------------------------
  136.   def add_choices(params, i, d = 0)
  137.     params[0].each_with_index {|s, n| $game_message.choices[n + d] = s }
  138.     $game_message.choice_cancel_type = params[1] + d if params[1] > 0
  139.     indent = @list.indent
  140.     loop do
  141.       i += 1
  142.       if @list.indent == indent
  143.         case @list.code
  144.         when 402 # [**] の場合
  145.           get_help_texts(@list.parameters[0] + d, i + 1)
  146.         when 404 # 分岐終了
  147.           break
  148.         end
  149.       end
  150.     end
  151.     i += 1
  152.     add_choices(@list.parameters, i, d + 5) if @list.code == 102
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● ヘルプ用テキストの取得
  156.   #--------------------------------------------------------------------------
  157.   def get_help_texts(b, i)
  158.     if @list.code == 108 && @list.parameters[0] == WdTk::ChoiceEX::Help
  159.       $game_message.choice_help = []
  160.       while @list[i + 1].code == 408
  161.         i += 1
  162.         $game_message.choice_help << @list.parameters[0]
  163.       end
  164.     end
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ◯ 注釈
  168.   #--------------------------------------------------------------------------
  169.   alias _wdtk_choice_command_108 command_108
  170.   def command_108
  171.     _wdtk_choice_command_108
  172.     @comments.each do |comment|
  173.       case comment
  174.       when /選択肢位置\((\d+),\s*(\d+),?\s*(\d*)\)/
  175.         $game_message.choice_x = $1.to_i
  176.         $game_message.choice_y = $2.to_i
  177.         $game_message.choice_row_max = ($3.empty? ? 99 : $3.to_i)
  178.       when /カーソル記憶\((\d+)\)/
  179.         $game_message.choice_var_id = $1.to_i
  180.       when /背景(ON|OFF)/
  181.         $game_message.choice_background = ($1 == "ON" ? 0 : 1)
  182.       end
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ☆ 分岐終了の場合
  187.   #--------------------------------------------------------------------------
  188.   def command_404
  189.     if next_event_code == 102
  190.       @branch[@indent] -= 5 if @branch.include?(@indent)
  191.       @index += 1
  192.       command_skip
  193.     end
  194.   end
  195. end

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

  333. #==============================================================================
  334. # ■ Window_Message
  335. #==============================================================================
  336. class Window_Message
  337.   #--------------------------------------------------------------------------
  338.   # ○ ウィンドウ背景の更新
  339.   #--------------------------------------------------------------------------
  340.   alias _wdtk_choice_update_background update_background
  341.   def update_background
  342.     _wdtk_choice_update_background
  343.     @choice_window.opacity = $game_message.choice_background == 0 ? 255 : 0
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● 文章の標示を強制クリア
  347.   #--------------------------------------------------------------------------
  348.   def force_clear
  349.     @gold_window.close
  350.     @fiber = nil
  351.     close
  352.     if WdTk.include?(:MesEff)
  353.       @character_sprites.each do |sprite, params|
  354.         next if params.empty?
  355.         sprite.bitmap.clear
  356.         sprite.visible = false
  357.         params.clear
  358.       end
  359.     end
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # ● 文章を最後まで表示する
  363.   #--------------------------------------------------------------------------
  364.   def on_show_fast
  365.     @show_fast = true
  366.   end
  367. end[/pre]
复制代码



別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~

Lv5.捕梦者

梦石
0
星屑
24364
在线时间
5054 小时
注册时间
2016-3-8
帖子
1622
2
发表于 2021-10-17 18:35:23 | 只看该作者
资讯不足, 无法解答,不用謝。
回复 支持 反对

使用道具 举报

Lv6.析梦学徒

老鹰

梦石
40
星屑
33422
在线时间
6553 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

3
发表于 2021-10-17 22:58:34 | 只看该作者
把这个脚本复制到主楼,用
  1. 代码块
复制代码

点评

?  发表于 2021-10-18 11:51
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3093
在线时间
344 小时
注册时间
2021-10-18
帖子
157
4
发表于 2021-10-18 15:33:47 | 只看该作者
那个empty?的判断没找到,是你动过继承还是不小心删改了方法?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
5
 楼主| 发表于 2021-10-20 16:41:18 | 只看该作者
百里_飞柳 发表于 2021-10-17 22:58
把这个脚本复制到主楼,用

抱歉哈哈…代碼塊不熟悉,腳本丟在上面了,感謝0.0..
別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
6
 楼主| 发表于 2021-10-23 22:40:22 | 只看该作者
掘窖人 发表于 2021-10-18 15:33
那个empty?的判断没找到,是你动过继承还是不小心删改了方法?

我這個腳本是做到一半才加入的。
別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~
回复 支持 反对

使用道具 举报

Lv4.逐梦者

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

开拓者

7
发表于 2021-10-24 00:03:35 | 只看该作者
本帖最后由 gqxastg 于 2021-10-24 00:52 编辑

在选择肢脚本后新开一页插入这个
RUBY 代码复制
  1. class Game_Message
  2.   def choice_help
  3.     return @choice_help if @choice_help
  4.     @choice_x = @choice_y = nil
  5.     @choice_row_max = WdTk::ChoiceEX::RowMax
  6.     @choice_help = {}
  7.     @choice_var_id = 0
  8.     @choice_background = 0
  9.     @under_choice = false
  10.     return @choice_help
  11.   end
  12. end
另外这个选择肢脚本其实版本更新到3.7了,建议更新一下
http://woodpenguin.web.fc2.com/rgss3/choice_ex.txt
备份

顺便一提使用代码块的方法是:高级模式下点击选项栏右上角“<>”样子的图标(会显示“添加代码文字”),然后把脚本代码粘贴到弹出框中最大的输入框里,再点“提交”即可
(建议保持勾选“纯文本”)
就算不进入高级模式也有相同的图标(会显示“代码”),方法一样

评分

参与人数 1+1 收起 理由
alexncf125 + 1 精品文章

查看全部评分

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

使用道具 举报

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
8
 楼主| 发表于 2021-10-24 14:19:20 | 只看该作者
gqxastg 发表于 2021-10-24 00:03
在选择肢脚本后新开一页插入这个
class Game_Message
  def choice_help

原來如此!感謝您!已經解決了。
別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
9
 楼主| 发表于 2021-10-24 14:30:31 | 只看该作者
gqxastg 发表于 2021-10-24 00:03
在选择肢脚本后新开一页插入这个
class Game_Message
  def choice_help

不過又是之前一樣的問題……
我已經照腳本上的註釋打上『選択肢位置(X/Y)』位置
但選擇框還是在右下…

点评

英语括号,应该是这样的 選択肢位置(150, 200)  发表于 2021-10-24 15:32
別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
941
在线时间
157 小时
注册时间
2016-8-25
帖子
117
10
 楼主| 发表于 2021-10-24 18:49:07 | 只看该作者
黑雪哲也 发表于 2021-10-24 14:30
不過又是之前一樣的問題……
我已經照腳本上的註釋打上『選択肢位置(X/Y)』位置
但選擇框還是在右下 ...

喔喔,原來是這樣=w=b....再次感謝!
別名:黑幽。
一個社恐的遊戲與畫圖愛好者。
路過的各位請關注一下~感謝~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 05:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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