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

Project1

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

[已经解决] 如何使用這個選項擴張腳本...

[复制链接]

Lv1.梦旅人

梦石
0
星屑
180
在线时间
54 小时
注册时间
2012-12-28
帖子
31
跳转到指定楼层
1
发表于 2013-6-11 19:38:36 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wai781300 于 2013-6-11 19:40 编辑

RUBY 代码复制
  1. =begin
  2. #==============================================================================
  3. [名前]    選択肢の拡張
  4. [作者]    焼きノリ
  5. [配布元]  まったりツクール雑貨 [url]http://mata-tuku.ldblog.jp/[/url]
  6. #------------------------------------------------------------------------------
  7. [更新履歴]
  8. ・2012/08/30 公開
  9. #==============================================================================
  10.  
  11. #------------------------------------------------------------------------------
  12. [対応]
  13. ・RGSS3のみ
  14. #------------------------------------------------------------------------------
  15.  
  16. #------------------------------------------------------------------------------
  17. [機能]
  18. ・以下の機能を追加した選択肢を扱うことができるようになります。
  19. ・選択項目数の制限が無くなり、5つ以上の選択肢を表示することが可能です。
  20.   ただし上限が無いので、あまりに選択数が多いと画面からはみ出るので注意。
  21. ・メッセージウィンドウは事前に自動で閉じます。
  22. ・選択肢の表示位置が画面中央になります。引数でデフォルトの位置にすることも可能。
  23. #------------------------------------------------------------------------------
  24.  
  25. #------------------------------------------------------------------------------
  26. [使用方法]
  27. ・ExChoice.push(text)    選択項目予約配列の末尾に文字列を追加します。
  28. ・ExChoice.insert(text)  選択項目予約配列の先頭に文字列を追加します。
  29. ・ExChoice.clear         選択項目予約配列を初期化します。自動でも呼ばれます。
  30. ・ExChoice.size          選択項目予約配列のサイズを取得します。
  31. ・setup_ex_choices([centering])  選択肢拡張機能を実行します。
  32.                                    選択肢が空の場合はキャンセルとみなします。
  33. 引数 : centering : ウィンドウを画面中央に表示するか。
  34.                           未指定の場合、trueになります。
  35. #------------------------------------------------------------------------------
  36. [再定義箇所]
  37. ・Window_ChoiceList の make_command_list
  38. #------------------------------------------------------------------------------
  39.   [○ : 新規定義,  ◎ : エイリアス定義,  ● : 再定義]
  40. #------------------------------------------------------------------------------
  41. =end
  42. $YkNr_Scripts ||= {}
  43. $YkNr_Scripts[:ExChoice] = true
  44. #※このスクリプトを使用しない場合は、↑を false にすること
  45.  
  46. if $YkNr_Scripts[:ExChoice]
  47. #==============================================================================
  48. # ■ ExChoice
  49. #------------------------------------------------------------------------------
  50. #     拡張選択肢を扱うためのモジュールです。
  51. #==============================================================================
  52. module YakiNori::BaseExModules::ExChoice
  53. #==============================================================================
  54. # ■ 定数モジュール
  55. #==============================================================================
  56. module Const
  57.   #==============================================================================
  58.   # ▼ カスタマイズ
  59.   #==============================================================================
  60.   # 選択肢拡張機能の結果値を保存する変数番号
  61.   #   キャンセル時は CancelExChoiceIndex を返します。
  62.   SaveResultVariableNum = 41
  63.   # 選択肢ウィンドウの位置を画面中央に表示するスイッチの番号
  64.   CenteringWindowSwitchNum = 19
  65.   #==============================================================================
  66.   # ▲ カスタマイズここまで
  67.   #==============================================================================
  68.   # キャンセル時に代入される値
  69.   CancelExChoiceIndex = -1
  70. end
  71. YakiNori.freeze_all_constants(self)  # 定数をフリーズ
  72. #==============================================================================
  73. # ■ 特異メソッド
  74. #==============================================================================
  75.   #--------------------------------------------------------------------------
  76.   # ○ 値の取得
  77.   #--------------------------------------------------------------------------
  78.   def self.list
  79.     $game_system.ex_choice_list
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ○ Ex選択肢項目を末尾に追加
  83.   #--------------------------------------------------------------------------
  84.   def self.push(text)
  85.     list.push(text.to_s)
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ○ Ex選択肢項目を先頭に追加
  89.   #--------------------------------------------------------------------------
  90.   def self.insert(text)
  91.     list.insert(0, text.to_s)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ○ Ex選択肢項目のクリア
  95.   #--------------------------------------------------------------------------
  96.   def self.clear
  97.     list.__send__ :clear
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ○ Ex選択肢項目の数の取得
  101.   #--------------------------------------------------------------------------
  102.   def self.size
  103.     list.size
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ○ Ex選択肢機能を使用するか設定 :内部で使用されます
  107.   #--------------------------------------------------------------------------
  108.   def self.using(flag)
  109.     @use_this = flag
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ○ Ex選択肢機能を使用するか取得 :内部で使用されます
  113.   #--------------------------------------------------------------------------
  114.   def self.using?
  115.     @use_this
  116.   end
  117. end
  118.  
  119. #==============================================================================
  120. # ■ Game_System
  121. #==============================================================================
  122. class Game_System
  123.   #--------------------------------------------------------------------------
  124.   # ○ Ex選択肢項目
  125.   #--------------------------------------------------------------------------
  126.   def ex_choice_list
  127.     @ex_choice_list ||= []
  128.     @ex_choice_list
  129.   end
  130. end
  131.  
  132. #==============================================================================
  133. # ■ Game_Interpreter
  134. #==============================================================================
  135. class Game_Interpreter
  136.   #--------------------------------------------------------------------------
  137.   # ○ インクルード
  138.   #--------------------------------------------------------------------------
  139.   include YakiNori::BaseExModules::ExChoice::Const
  140.   #--------------------------------------------------------------------------
  141.   # ◎ 選択肢の表示
  142.   #--------------------------------------------------------------------------
  143.   alias yknr_ExChoice_command_102 command_102
  144.   def command_102
  145.     yknr_ExChoice_command_102
  146.     $game_switches[CenteringWindowSwitchNum] = false
  147.     ExChoice.using(false)
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ◎ 選択肢のセットアップ
  151.   #--------------------------------------------------------------------------
  152.   alias yknr_ExChoice_setup_choices setup_choices
  153.   def setup_choices(params)
  154.     if ExChoice.using?
  155.       ExChoice.list.each {|s| $game_message.choices.push(s) }
  156.       ExChoice.clear
  157.       $game_message.choice_cancel_type = 5
  158.     else
  159.       yknr_ExChoice_setup_choices(params)
  160.     end
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ○ Ex選択肢のセットアップ
  164.   #--------------------------------------------------------------------------
  165.   def setup_ex_choices(centering = true)
  166.     ExChoice.clear if ExChoice.list.nil?
  167.     if ExChoice.list.empty?
  168.       $game_variables[SaveResultVariableNum] = CancelExChoiceIndex
  169.       return
  170.     end
  171.     $game_switches[CenteringWindowSwitchNum] = centering
  172.     ExChoice.using(true)
  173.     command_102
  174.   end
  175. end
  176.  
  177. #==============================================================================
  178. # ■ Window_ChoiceList
  179. #==============================================================================
  180. class Window_ChoiceList < Window_Command
  181.   #--------------------------------------------------------------------------
  182.   # ○ インクルード
  183.   #--------------------------------------------------------------------------
  184.   include YakiNori::BaseExModules::ExChoice::Const
  185.   #--------------------------------------------------------------------------
  186.   # ◎ ウィンドウ位置の更新
  187.   #--------------------------------------------------------------------------
  188.   alias yknr_ExChoice_update_placement update_placement
  189.   def update_placement
  190.     if $game_switches[CenteringWindowSwitchNum]
  191.       self.width = [max_choice_width + 12, 96].max + padding * 2
  192.       self.width = [width, Graphics.width].min
  193.       self.height = fitting_height($game_message.choices.size)
  194.       self.x = (Graphics.width / 2) - (width / 2)   # 真ん中へ
  195.       self.y = (Graphics.height / 2) - (height / 2) # 真ん中へ
  196.     else
  197.       yknr_ExChoice_update_placement
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● コマンドリストの作成
  202.   #--------------------------------------------------------------------------
  203.   def make_command_list
  204.     $game_message.choices.each do |choice|
  205.       add_command(choice, :ok)
  206.     end
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ◎ 決定ハンドラの呼び出し
  210.   #--------------------------------------------------------------------------
  211.   alias yknr_ExChoice_call_ok_handler call_ok_handler
  212.   def call_ok_handler
  213.     if ExChoice.using?
  214.       $game_variables[SaveResultVariableNum] = index
  215.       close
  216.     else
  217.       yknr_ExChoice_call_ok_handler
  218.     end
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ◎ キャンセルハンドラの呼び出し
  222.   #--------------------------------------------------------------------------
  223.   alias yknr_ExChoice_call_cancel_handler call_cancel_handler
  224.   def call_cancel_handler
  225.     if ExChoice.using?
  226.       $game_variables[SaveResultVariableNum] = CancelExChoiceIndex
  227.       close
  228.     else
  229.       yknr_ExChoice_call_cancel_handler
  230.     end
  231.   end
  232. end
  233. end #$YkNr_Scripts
這是一個選項擴張的腳本,但我怎看怎試也用不了,有哪位大哥可以教一下嗎ORZ

附上另一個介紹網址ORZ

它需要一個基礎腳本,上方的連結有下載...我已經兩個也放在MAIN上面了ORZ
不論是在事件的腳本上輸入使用方法那些代碼
還是注釋都試過了,這東西究竟怎麼用啊{:2_270:}

Lv1.梦旅人

梦石
0
星屑
50
在线时间
89 小时
注册时间
2012-12-12
帖子
8
2
发表于 2013-6-11 23:29:10 | 只看该作者
本帖最后由 eddlion 于 2013-6-12 00:12 编辑

{:2_272:} 这个脚本大概是这样用的    首先把俩个脚本都放到脚本编辑器里
然后用事件上添加脚本:
ExChoice.push(text)    这个是在最后一个选项后添加一个选项 。TEXT为选项的内容 ,比如"是"、"否"之类的 中文记得加"" 双引号
ExChoice.insert(text)   这个是在第一个选项前添加一个选项 。
ExChoice.clear         清除因选项后而产生的数据 变量就是了  最好在每次使用这种选项框前加上这句
ExChoice.size         不明  大概和尺寸有关 不填好像也可以
setup_ex_choices([centering])  不明     必要语句   centering我是随便填一个数,具体这个数字有什么用不清楚

注: 使用了这个脚本,选项框的位置会变为在窗口的中央 请看情况决定要不要使用



最后在選項擴張的腳本里的63行是为选项提供一个变量  默认是41号
比如你按第一个选项41这个变量的值 就会变成0
按第二个选项这个变量就会变成1

接下来 直接用事件判断变量41就可以了


附图

可能有说错的地方{:2_282:}
不过基本能用就是  请其他前辈补充和改正

评分

参与人数 1星屑 +100 收起 理由
Sion + 100 感谢帮忙

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
144
在线时间
628 小时
注册时间
2012-6-9
帖子
1321
3
发表于 2013-6-12 12:45:55 | 只看该作者
  1.   alias yknr_ExChoice_update_placement update_placement
  2.   def update_placement
  3.     if $game_switches[CenteringWindowSwitchNum]
  4.       self.width = [max_choice_width + 12, 96].max + padding * 2
  5.       self.width = [width, Graphics.width].min
  6.       self.height = fitting_height($game_message.choices.size)
  7.       self.x = (Graphics.width / 2) - (width / 2)   # 真ん中へ
  8.       self.y = (Graphics.height / 2) - (height / 2) # 真ん中へ
  9.     else
复制代码
看到坐标的说。

评分

参与人数 1星屑 +50 收起 理由
Sion + 50 感谢帮忙

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22032
在线时间
8575 小时
注册时间
2011-12-31
帖子
3362
4
发表于 2013-6-13 06:57:32 | 只看该作者
A1的選項拡張更簡単

评分

参与人数 1星屑 +50 收起 理由
Sion + 50 感谢帮忙

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
135 小时
注册时间
2013-6-10
帖子
29
5
发表于 2013-6-13 10:06:02 | 只看该作者

RE: 如何使用這個選項擴張腳本...

本帖最后由 xTsukihime 于 2013-6-29 07:42 编辑

覺得這ExChoice太難用了。
试一试Large Choices。

[spoiler]

  1. =begin
  2. #==============================================================================
  3. ** Large Choices
  4. Author: Tsukihime
  5. Date: Apr 10, 2013
  6. ------------------------------------------------------------------------------
  7. ** Change log
  8. Apr 10, 2013
  9.    - added option to disable automatic show combining
  10. Mar 26, 2013
  11.    - fixed bug where cancel choice was not properly updated
  12. Jan 12, 2013
  13.    - fixed bug where the first set of nested options were numbered incorrectly
  14. Dec 7, 2012
  15.    - implemented proper branch canceling
  16. Dec 6, 2012
  17.    - Initial release
  18. ------------------------------------------------------------------------------   
  19. ** Terms of Use
  20. * Free to use in commercial/non-commercial projects
  21. * No real support. The script is provided as-is
  22. * Will do bug fixes, but no compatibility patches
  23. * Features may be requested but no guarantees, especially if it is non-trivial
  24. * Preserve this header
  25. ------------------------------------------------------------------------------
  26. ** Description

  27. This script combines groups of "show choice" options together as one large
  28. command. This allows you to create more than 4 choices by simply creating
  29. several "show choice" commands.
  30. ------------------------------------------------------------------------------
  31. ** Usage

  32. Add a show choice command.
  33. If you want more choices, add another one, and fill it out as usual.

  34. Note that you should only specify one cancel choice (if you specify more than
  35. one, then the last one is taken).

  36. For "branch" canceling, note that *all* cancel branches are executed.
  37. You should only have a cancel branch on the last set of choices

  38. You can disable automatic choice combining by enabling the "Manual Combine"
  39. option, which will require you to make this script call before the first
  40. show choice command

  41.     combine_choices
  42.    
  43. In order to combine choices together
  44. #==============================================================================
  45. =end
  46. $imported = {} if $imported.nil?
  47. $imported["TH_LargeChoices"] = true
  48. #==============================================================================
  49. # ** Configuration
  50. #==============================================================================
  51. module TH
  52.   module Large_Choices
  53.    
  54.     # Turning this option on will require you to manually specify that
  55.     # a sequence of Show Choice options should be combined
  56.     Manual_Combine = false
  57.    
  58. #==============================================================================
  59. # ** Rest of the script
  60. #==============================================================================     
  61.     Code_Filter = [402, 403, 404]
  62.     Regex = /<large choices>/i
  63.   end
  64. end

  65. class Game_Temp
  66.   
  67.   # temp solution to get this working
  68.   attr_accessor :branch_choice
  69.   
  70.   def branch_choice
  71.     @branch_choice || 5
  72.   end
  73. end

  74. class Game_Interpreter
  75.   
  76.   #-----------------------------------------------------------------------------
  77.   # Clean up
  78.   #-----------------------------------------------------------------------------
  79.   alias :th_large_choices_clear :clear
  80.   def clear
  81.     th_large_choices_clear
  82.     @first_choice_cmd = nil
  83.     @choice_search = 0
  84.     @combine_choices = false
  85.   end
  86.   
  87.   #-----------------------------------------------------------------------------
  88.   # Prepare for more choices
  89.   #-----------------------------------------------------------------------------
  90.   alias :th_large_choices_setup_choices :setup_choices
  91.   def setup_choices(params)
  92.     # start with our original choices
  93.     th_large_choices_setup_choices(params)
  94.    
  95.     return if TH::Large_Choices::Manual_Combine && !@combine_choices

  96.     # store our "first" choice in the sequence
  97.     @first_choice_cmd = @list[@index]
  98.    
  99.     # reset branch choice
  100.     $game_temp.branch_choice = @first_choice_cmd.parameters[1]
  101.    
  102.     # Start searching for more choices
  103.     @num_choices = $game_message.choices.size
  104.     @choice_search = @index + 1
  105.     search_more_choices
  106.   end
  107.   
  108.   def combine_choices
  109.     @combine_choices = true
  110.   end
  111.   
  112.   #-----------------------------------------------------------------------------
  113.   # New. Check whether the next command (after all branches) is another choice
  114.   # command. If so, merge it with the first choice command.
  115.   #-----------------------------------------------------------------------------
  116.   def search_more_choices
  117.     skip_choice_branches
  118.     next_cmd = @list[@choice_search]
  119.    
  120.     # Next command isn't a "show choice" so we're done
  121.     return if next_cmd.code != 102
  122.    
  123.     @choice_search += 1
  124.     # Otherwise, push the choices into the first choice command to merge
  125.     # the commands.
  126.     @first_choice_cmd.parameters[0].concat(next_cmd.parameters[0])
  127.    
  128.     # Update all cases to reflect merged choices
  129.     update_show_choices(next_cmd.parameters)
  130.     update_cancel_choice(next_cmd.parameters)
  131.     update_choice_numbers
  132.    
  133.     # delete the command to effectively merge the branches
  134.     @list.delete(next_cmd)
  135.    
  136.     # Now search for more
  137.     search_more_choices
  138.   end

  139.   #-----------------------------------------------------------------------------
  140.   # New. Update the options for the first "show choice" command
  141.   #-----------------------------------------------------------------------------
  142.   def update_show_choices(params)
  143.     params[0].each {|s| $game_message.choices.push(s) }
  144.   end
  145.   
  146.   #-----------------------------------------------------------------------------
  147.   # New. If cancel specified, update it to reflect merged choice numbers
  148.   # The last one is taken if multiple cancel choices are specified
  149.   #-----------------------------------------------------------------------------
  150.   def update_cancel_choice(params)
  151.    
  152.     # disallow, just ignore
  153.     return if params[1] == 0   
  154.    
  155.     # branch on cancel
  156.     return update_branch_choice if params[1] == 5
  157.    
  158.     # num_choices is not one-based
  159.     cancel_choice = params[1] + (@num_choices)
  160.     # update cancel choice, as well as the first choice command
  161.     $game_message.choice_cancel_type = cancel_choice
  162.     @first_choice_cmd.parameters[1] = cancel_choice
  163.   end
  164.   
  165.   #-----------------------------------------------------------------------------
  166.   # New. Set the initial choice command to "branch cancel"
  167.   #-----------------------------------------------------------------------------
  168.   def update_branch_choice
  169.     branch_choice = $game_message.choices.size + 1
  170.     $game_message.choice_cancel_type = branch_choice
  171.     $game_temp.branch_choice = branch_choice
  172.     @first_choice_cmd.parameters[1] = branch_choice
  173.   end
  174.   
  175.   def command_403
  176.     command_skip if @branch[@indent] != $game_temp.branch_choice - 1
  177.   end
  178.   
  179.   #-----------------------------------------------------------------------------
  180.   # New. For each branch, update it to reflect the merged choice numbers.
  181.   #-----------------------------------------------------------------------------
  182.   def update_choice_numbers
  183.    
  184.     # Begin searching immediately after cmd 102 (show choice)
  185.     i = @choice_search
  186.    
  187.     # Rough search for "When" commands. The search must skip nested commands
  188.     while TH::Large_Choices::Code_Filter.include?(@list[i].code) || @list[i].indent != @indent
  189.       if @list[i].code == 402 && @list[i].indent == @indent
  190.         @list[i].parameters[0] = @num_choices
  191.         @num_choices += 1
  192.       end
  193.       i += 1
  194.     end
  195.   end
  196.   
  197.   #-----------------------------------------------------------------------------
  198.   # New. Returns the next command after our choice branches
  199.   #-----------------------------------------------------------------------------
  200.   def skip_choice_branches
  201.     # start search at the next command
  202.     # skip all choice branch-related commands and any branches
  203.     while TH::Large_Choices::Code_Filter.include?(@list[@choice_search].code) || @list[@choice_search].indent != @indent
  204.       @choice_search += 1
  205.     end
  206.     return @choice_search
  207.   end
  208. end
复制代码
[/spoiler]

http://himeworks.wordpress.com/2 ... n-multiple-choices/

用法:把幾個連起來就好了。


large_choice1.jpg (92.17 KB, 下载次数: 22)

large_choice1.jpg

large_choice2.jpg (92.8 KB, 下载次数: 21)

large_choice2.jpg

评分

参与人数 1星屑 +100 收起 理由
Sion + 100 感谢帮忙

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-16 15:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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