じ☆ve冰风 发表于 7 天前

SAI Key Item Button

SAI Key Item Button v1.0

Bishop Myers ("Sailerius")



Introduction

Inspired by Chrono Cross, this script allows you to call the Key Item dialog box at any time on the map. You can make it such that selecting an item from the dialog box will activate an adjacent action button events so that they can respond to the item used.

Features

- Adds the ability to call the key item dialog box at any time with a key

- Allows doing so to cause events to respond

- Stores ID number of used item into a variable for easy checking

How to Use

Just paste it in. Follow the instructions in the script and customize the callback methods to get the effect that you want.

Script



                Code:        
#============================================================================== # # ▼ SAI Key Item Button v1.0 # -- Last Updated: 2012.04.22 # -- Author: Bishop Myers ("Sailerius") # -- Requires: n/a # #============================================================================== $imported = {} if $imported.nil? $imported["SAI-KeyItemButton"] = true #============================================================================== # ▼ Updates # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # 2012.01.12 - First release # #============================================================================== # ▼ Introduction # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Inspired by Chrono Cross, this script allows you to call the Key Item dialog # box at any time on the map. You can make it such that selecting an item from # the dialog box will activate an adjacent action button events so that they # can respond to the item used. # #============================================================================== # ▼ Instructions # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # To install this script, open up your script editor and copy/paste this script # to an open slot below ▼ Materials but above ▼ Main. Remember to save. # # To customize the script, make any edits you wish to the callback methods # defined below. # # key_item_trigger? #   When this method returns true, the key item dialog will be called. By #   default, it checks if the X button (A key) is triggered. Feel free to change #   this to a different button, or give it a different condition altogether. # # key_item_variable #   This method returns an integer which tells the script which variable to #   save the ID number of the key item used to. By default, it returns 2, #   meaning that using a key item will save its ID to variable #2. # # call_action_events_after_key_item_dialog? #   This method returns true if using a key item from the key item dialog should #   trigger action button events. By default, it returns true. # # call_action_events_after_key_item_dialog_cancelled? #   This method returns true if cancelling the key item dialog should trigger #   action button events. By default, it returns false. # # can_call_key_item_dialog_while_moving? #   This method returns true if the player should be able to call the key item #   dialog while moving. By default, it returns false. #============================================================================== # ▼ Compatibility # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script should be fully compatible with any other well-written Ace # scripts. # #=============================================================================== # ■ Game_Player #=============================================================================== class Game_Player < Game_Character   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=   # ▼ Callback Methods   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=   # These methods are designed to be customized and redefined to suit the needs   # of your project. They are called throughout the script, so it is crucial   # that you do not change the method name or arguments unless you know what   # you're doing.   #-----------------------------------------------------------------------------   # Function to determine what condition triggers the key item dialog   #-----------------------------------------------------------------------------   def key_item_trigger?         Input.trigger?(:X)   end   #-----------------------------------------------------------------------------   # Variable number in which to store the key item the player selects   #-----------------------------------------------------------------------------   def key_item_variable         return 2   end   #-----------------------------------------------------------------------------   # Should adjacent action events be called if the key item dialog is called?   #-----------------------------------------------------------------------------   def call_action_events_after_key_item_dialog?         return true   end   #-----------------------------------------------------------------------------   # Should adjacent action events be called if the key item dialog was cancelled?   #-----------------------------------------------------------------------------   def call_action_events_after_key_item_dialog_cancelled?         return false   end   #-----------------------------------------------------------------------------   # Should the player be able to use the key item dialog while moving?   #-----------------------------------------------------------------------------   def can_call_key_item_dialog_while_moving?         return false   end #=============================================================================== # ▼ Editing below is not intended for beginners. Change at your own risk. #===============================================================================   #-----------------------------------------------------------------------------   # Adds functionality to check for key item button   #-----------------------------------------------------------------------------   alias :gameplayer_update_saikib :update   def update         gameplayer_update_saikib         if ((movable? || can_call_key_item_dialog_while_moving?) && key_item_trigger?)           setup_item_choice(key_item_variable)         end   end   #-----------------------------------------------------------------------------   # Brings up the key item choice dialog and sets result to variable_number   #-----------------------------------------------------------------------------   def setup_item_choice(variable_number)         $game_message.item_choice_variable_id = variable_number   end end #=============================================================================== # ■ Window_KeyItem #=============================================================================== class Window_KeyItem < Window_ItemList   #-----------------------------------------------------------------------------   # Added functionality to call action events after an item is selected   #-----------------------------------------------------------------------------   alias :window_keyitem_on_ok_saikib :on_ok   def on_ok         window_keyitem_on_ok_saikib         if $game_player.call_action_events_after_key_item_dialog?           $game_player.check_action_event         end   end   #-----------------------------------------------------------------------------   # Added functionality to call action events after cancelling the key item dialog   #-----------------------------------------------------------------------------   alias :window_keyitem_on_cancel_saikib :on_cancel   def on_cancel         window_keyitem_on_cancel_saikib         if $game_player.call_action_events_after_key_item_dialog_cancelled?           $game_player.check_action_event         end   end end

FAQ

No questions yet asked.


本贴来自国际rpgmaker官方论坛作者:marblejudge处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/sai-key-item-button.1536/
页: [1]
查看完整版本: SAI Key Item Button