Project1

标题: 问下在游戏里怎么调用这个脚本? [打印本页]

作者: lottesong    时间: 2013-9-22 07:54
标题: 问下在游戏里怎么调用这个脚本?
本帖最后由 lottesong 于 2013-9-22 19:39 编辑

答案见1L   >ω<

----------------------------

日文苦手   谢谢

比如想调出来一个物品 注释栏含有<gift>的所有道具窗口  
用如下的脚本
$game_message.item_choice_category = "gift"

为什么不好使啊 啥反应也木有? 其他  用:weapon  用:item也都一样不好使……

orz 都需要什么条件
  里面的PLUS_ID是做什么用的 必须要修改吗才能显示?

原地址
http://cacaosoft.web.fc2.com/tkool/script/rgss3/itemchoice.html

RUBY 代码复制
  1. #******************************************************************************
  2. #
  3. #    * アイテム選択の処理
  4. #
  5. #  --------------------------------------------------------------------------
  6. #    バージョン :  1.2.0
  7. #    対      応 :  RPGツクールVX Ace : RGSS3
  8. #    制  作  者 :  CACAO
  9. #    配  布  元 :  [url]http://cacaosoft.web.fc2.com/[/url]
  10. #  --------------------------------------------------------------------------
  11. #   == 概    要 ==
  12. #
  13. #   : キーアイテム以外のものも選べるようにします。
  14. #   : ヘルプウィンドウを表示する機能を追加します。
  15. #
  16. #  --------------------------------------------------------------------------
  17. #   == 注意事項 ==
  18. #
  19. #    ※ 変数には、IDではなくアイテムのデータが代入されます。
  20. #    ※ 選択しなかった場合は 0 が代入されます。
  21. #
  22. #  --------------------------------------------------------------------------
  23. #   == 使用方法 ==
  24. #
  25. #    ★ 選択アイテムの設定する
  26. #     $game_message.item_choice_category にキーワードを代入してください。
  27. #     :all      .. すべての所持品
  28. #     :all_item .. すべてのアイテム
  29. #     :item     .. キーアイテム以外のアイテム
  30. #     :weapon   .. すべての武器
  31. #     :armor    .. すべての防具
  32. #     :equip    .. 武器と防具
  33. #     :sell     .. キーアイテム以外で価格が0でないもの
  34. #     "keyword" .. メモ欄に <keyword> と書かれているもの
  35. #
  36. #    ★ ショップアイテムから選択する
  37. #     $game_message.item_choice_from_goods = true
  38. #     このスクリプトを実行後、ショップの処理でアイテムを設定してください。
  39. #
  40. #    ★ 所持数を非表示にする
  41. #     $game_message.item_choice_hide_number = true
  42. #
  43. #    ★ キャンセルを無効にする
  44. #     $game_message.item_choice_cancel_disabled = true
  45. #
  46. #    ★ 未所持アイテムも表示する
  47. #     $game_message.item_choice_show_nothing = true
  48. #
  49. #    ※ 上記4つの設定は、アイテム選択の処理後に初期化されます。
  50. #
  51. #    ★ アイテム選択ウィンドウの行数を変更する
  52. #     $game_message.item_choice_line = 行数
  53. #
  54. #    ★ ヘルプウィンドウの行数を変更する
  55. #     $game_message.item_choice_help_line = 行数
  56. #     ※ 0 のときは、ヘルプウィンドウが非表示になります。
  57. #
  58. #    ★ カテゴリのアイテム所持数を取得する
  59. #     $game_party.item_count(category)
  60. #     category は、$game_message.item_choice_category と同じものです。
  61. #
  62. #
  63. #******************************************************************************
  64.  
  65.  
  66. #==============================================================================
  67. # ◆ 設定項目
  68. #==============================================================================
  69. module CAO
  70. module ItemChoice
  71.  
  72.   #--------------------------------------------------------------------------
  73.   # ◇ 種類によるIDの増加値
  74.   #--------------------------------------------------------------------------
  75.   PLUS_ID = 0
  76.   #--------------------------------------------------------------------------
  77.   # ◇ 行数の設定 (初期値)
  78.   #--------------------------------------------------------------------------
  79.   ITEM_LINE = 4       # アイテム選択ウィンドウ
  80.   HELP_LINE = 0       # ヘルプウィンドウ ( 0 のとき非表示)
  81.   #--------------------------------------------------------------------------
  82.   # ◇ 表示位置の設定
  83.   #--------------------------------------------------------------------------
  84.   POS_TOP = false
  85.  
  86. end # module ItemChoice
  87. end # module CAO
  88.  
  89.  
  90. #/////////////////////////////////////////////////////////////////////////////#
  91. #                                                                             #
  92. #                下記のスクリプトを変更する必要はありません。                 #
  93. #                                                                             #
  94. #/////////////////////////////////////////////////////////////////////////////#
  95.  
  96.  
  97. class CAO::Dummy_ItemList < Window_ItemList
  98.   #--------------------------------------------------------------------------
  99.   # ● メソッド定義の取り消し
  100.   #--------------------------------------------------------------------------
  101.   # undef_method *self.superclass.instance_methods(false)
  102.   # def include?(item); super; end
  103.   #--------------------------------------------------------------------------
  104.   # ● オブジェクト初期化
  105.   #--------------------------------------------------------------------------
  106.   def initialize
  107.     @category = :none
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● カテゴリのアイテム所持数を取得
  111.   #--------------------------------------------------------------------------
  112.   def count(category)
  113.     @category = category
  114.     return $game_party.all_items.count {|item| include?(item) }
  115.   end
  116. end
  117.  
  118. class Game_Party
  119.   #--------------------------------------------------------------------------
  120.   # ● カテゴリのアイテム所持数を取得
  121.   #--------------------------------------------------------------------------
  122.   def item_count(category)
  123.     return CAO::Dummy_ItemList.new.count(category)
  124.   end
  125. end
  126.  
  127. class Game_Message
  128.   #--------------------------------------------------------------------------
  129.   # ● 公開インスタンス変数
  130.   #--------------------------------------------------------------------------
  131.   attr_accessor :item_choice_category         # アイテム選択 カテゴリ
  132.   attr_accessor :item_choice_from_goods       # アイテム選択 商品から選択
  133.   attr_accessor :item_choice_goods            # アイテム選択 選択アイテム
  134.   attr_accessor :item_choice_hide_number      # アイテム選択 所持数非表示
  135.   attr_accessor :item_choice_cancel_disabled  # アイテム選択 キャンセル無効
  136.   attr_accessor :item_choice_show_nothing     # アイテム選択 未所持でも表示
  137.   attr_accessor :item_choice_line             # アイテム選択 行数
  138.   attr_accessor :item_choice_help_line        # アイテム選択 ヘルプの行数
  139.   #--------------------------------------------------------------------------
  140.   # ●
  141.   #--------------------------------------------------------------------------
  142.   def clear_item_choice
  143.     @item_choice_category = :key_item
  144.     @item_choice_from_goods = false
  145.     @item_choice_goods = []
  146.     @item_choice_hide_number = false
  147.     @item_choice_cancel_disabled = false
  148.     @item_choice_show_nothing = false
  149.   end
  150. end
  151.  
  152. class Game_Interpreter
  153.   #--------------------------------------------------------------------------
  154.   # ○ ショップの処理
  155.   #--------------------------------------------------------------------------
  156.   alias _cao_itemchoice_command_302 command_302
  157.   def command_302
  158.     if $game_message.item_choice_from_goods
  159.       goods = [@params]
  160.       while next_event_code == 605
  161.         [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  162.         goods.push(@list[@index].parameters)
  163.       end
  164.       $game_message.item_choice_goods = []
  165.       goods.each do |param|
  166.         case param[0]
  167.         when 0; item = $data_items[param[1]]
  168.         when 1; item = $data_weapons[param[1]]
  169.         when 2; item = $data_armors[param[1]]
  170.         end
  171.         $game_message.item_choice_goods.push(item) if item
  172.       end
  173.     else
  174.       _cao_itemchoice_command_302
  175.     end
  176.   end
  177. end
  178.  
  179. class Window_ItemList
  180.   #--------------------------------------------------------------------------
  181.   # ○ アイテムをリストに含めるかどうか
  182.   #--------------------------------------------------------------------------
  183.   alias _cao_itemchoice_include? include?
  184.   def include?(item)
  185.     case @category
  186.     when String
  187.       return item && item.note.include?("<#{@category}>")
  188.     when :all
  189.       return item != nil
  190.     when :all_item
  191.       return item.kind_of?(RPG::Item)
  192.     when :equip
  193.       return item.kind_of?(RPG::Weapon) || item.kind_of?(RPG::Armor)
  194.     when :sell
  195.       return false if item == nil
  196.       return false if item.respond_to?(:key_item?) && item.key_item?
  197.       return false if item.price == 0
  198.       return true
  199.     else
  200.       return _cao_itemchoice_include?(item)
  201.     end
  202.   end
  203. end
  204.  
  205. class Window_KeyItem
  206.   #--------------------------------------------------------------------------
  207.   # ◎ オブジェクト解放
  208.   #--------------------------------------------------------------------------
  209.   def dispose
  210.     @help_window.dispose if @help_window
  211.     super
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ◎ ウィンドウを開く
  215.   #--------------------------------------------------------------------------
  216.   def open
  217.     @help_window.open if @help_window
  218.     super
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ◎ ウィンドウを閉じる
  222.   #--------------------------------------------------------------------------
  223.   def close
  224.     @help_window.close if @help_window
  225.     super
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ◎ アイテムリストの作成
  229.   #--------------------------------------------------------------------------
  230.   alias _cao_itemchoice_make_item_list make_item_list unless $!
  231.   def make_item_list
  232.     if $game_message.item_choice_show_nothing
  233.       if $game_message.item_choice_from_goods
  234.         @data = $game_message.item_choice_goods
  235.       else
  236.         items = $data_items + $data_weapons + $data_armors
  237.         @data = items.select {|item| include?(item) }
  238.       end
  239.     else
  240.       if $game_message.item_choice_from_goods
  241.         @data = $game_party.all_items & $game_message.item_choice_goods
  242.       else
  243.         # super
  244.         _cao_itemchoice_make_item_list
  245.       end
  246.     end
  247.     create_help_window
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ●
  251.   #--------------------------------------------------------------------------
  252.   def create_help_window
  253.     $game_message.item_choice_line ||= CAO::ItemChoice::ITEM_LINE
  254.     $game_message.item_choice_help_line ||= CAO::ItemChoice::HELP_LINE
  255.     @help_window.dispose if @help_window
  256.     if $game_message.item_choice_help_line != 0
  257.       self.help_window = Window_Help.new($game_message.item_choice_help_line)
  258.       @help_window.openness = 0
  259.       @help_window.open
  260.     end
  261.     self.height = fitting_height($game_message.item_choice_line)
  262.     update_placement
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ○ アイテムを許可状態で表示するかどうか
  266.   #--------------------------------------------------------------------------
  267.   def enable?(item)
  268.     return true
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   # ●
  272.   #--------------------------------------------------------------------------
  273.   def variable=(value)
  274.     $game_variables[$game_message.item_choice_variable_id] = value
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ○ 決定時の処理
  278.   #--------------------------------------------------------------------------
  279.   def on_ok
  280.     if self.item == nil
  281.       self.variable = 0
  282.     elsif CAO::ItemChoice::PLUS_ID > 0
  283.       self.variable = self.item.id
  284.       case self.item
  285.       when RPG::Weapon
  286.         self.variable += CAO::ItemChoice::PLUS_ID
  287.       when RPG::Armor
  288.         self.variable += CAO::ItemChoice::PLUS_ID * 2
  289.       end
  290.     else
  291.       self.variable = self.item
  292.     end
  293.     close
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ○ キャンセル処理の有効状態を取得
  297.   #--------------------------------------------------------------------------
  298.   def cancel_enabled?
  299.     return false
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ◎ フレーム更新
  303.   #--------------------------------------------------------------------------
  304.   alias _cao_itemchoice_update update unless $!
  305.   def update
  306.     # super
  307.     _cao_itemchoice_update
  308.     @help_window.update if @help_window
  309.     if open? && self.active && Input.trigger?(:B)
  310.       Input.update
  311.       if $game_message.item_choice_cancel_disabled
  312.         Sound.play_buzzer
  313.       else
  314.         Sound.play_cancel
  315.         deactivate
  316.         on_cancel
  317.       end
  318.     end
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ○ ウィンドウ位置の更新
  322.   #--------------------------------------------------------------------------
  323.   def update_placement
  324.     if $game_message.item_choice_help_line == 0
  325.       help_height = 0
  326.     else
  327.       help_height = @help_window.height
  328.     end
  329.     if CAO::ItemChoice::POS_TOP
  330.       if @message_window.close?
  331.         self.y = help_height
  332.       elsif self.height + help_height < @message_window.y
  333.         self.y = help_height
  334.       else
  335.         self.y = @message_window.y + @message_window.height + help_height
  336.       end
  337.     else
  338.       mbh = Graphics.height - (@message_window.y + @message_window.height)
  339.       if @message_window.close?
  340.         self.y = Graphics.height - self.height
  341.       elsif self.height + help_height < mbh
  342.         self.y = Graphics.height - self.height
  343.       else
  344.         self.y = @message_window.y - self.height
  345.       end
  346.     end
  347.     if $game_message.item_choice_help_line != 0
  348.       @help_window.y = self.y - @help_window.height
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ○ アイテムの個数を描画
  353.   #--------------------------------------------------------------------------
  354.   alias _cao_itemchoice_draw_item_number draw_item_number
  355.   def draw_item_number(rect, item)
  356.     return if $game_message.item_choice_hide_number
  357.     _cao_itemchoice_draw_item_number(rect, item)
  358.   end
  359. end
  360.  
  361. class Window_Message
  362.   #--------------------------------------------------------------------------
  363.   # ○ アイテムの選択処理
  364.   #--------------------------------------------------------------------------
  365.   def input_item
  366.     @item_window.start
  367.     @item_window.category = ($game_message.item_choice_category || :key_item)
  368.     Fiber.yield while @item_window.active
  369.     $game_message.clear_item_choice
  370.   end
  371. end

作者: 熊喵酱    时间: 2013-9-22 08:34
本帖最后由 76213585 于 2013-9-21 19:28 编辑

发腳本時用代碼功能匡起來
這樣很難看懂......

============================

試了一下  終於懂了........

首先要先設好這个
  1. $game_message.item_choice_category = x
复制代码
你應該會
然後什么反應都沒有對吧......
原因是使用後必需要再用事件選項(第一頁)中的物品選則才會有反應
他是把可以選則的物品給括展了  並不會把窗口給喚出
所以要使用的事件應該是:
===============================
腳本: $game_message.item_choice_category = "gift"
物品選則處理: [X:變量的名字]
===============================
也就是會把選則的處量ID套入X變量
作者: 熊喵酱    时间: 2013-9-22 09:02
TO版主:連帖請原諒.....
其實我沒看到他在指令有定義
  1. :key_item
复制代码
的樣子......

是因為默認的道具選取(事件頁內有)
就是只有貴重物品的
直接使用事件內的選項就行了




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1