Guest User

Message Skip Enhanced

a guest
May 16th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.44 KB | Source Code | 0 0
  1. =begin
  2. #===============================================================================
  3.  Title: Message Skip
  4.  Author: Hime
  5.  Date: Jul 21, 2013
  6. --------------------------------------------------------------------------------
  7.  ** Change log
  8.  Jul 21, 2013
  9.    - Initial release
  10. --------------------------------------------------------------------------------  
  11.  ** Terms of Use
  12.  * Free to use in non-commercial projects
  13.  * Contact me for commercial use
  14.  * No real support. The script is provided as-is
  15.  * Will do bug fixes, but no compatibility patches
  16.  * Features may be requested but no guarantees, especially if it is non-trivial
  17.  * Credits to Hime Works in your project
  18.  * Preserve this header
  19. --------------------------------------------------------------------------------
  20.  ** Description
  21.  
  22.  This script allows you to skip messages (fast-forward) by holding down the
  23.  CTRL key.
  24.  
  25. --------------------------------------------------------------------------------
  26.  ** Installation
  27.  
  28.  Place this script below Materials and above Main
  29.  
  30. --------------------------------------------------------------------------------
  31.  ** Usage
  32.  
  33.  You can choose which key will be used as the skip key.
  34.  
  35.  You can enable or disable message skipping by assigning a disable switch.
  36.  When the disable switch is ON, players cannot skip messages.
  37. --------------------------------------------------------------------------------
  38.  ** Compatibility
  39.  
  40.  This script overwrites the following methods
  41.  
  42.    Window_Message
  43.      input_pause
  44.  
  45. #===============================================================================
  46. =end
  47. $imported = {} if $imported.nil?
  48. $imported["TH_MessageSkip"] = true
  49. #===============================================================================
  50. # ** Configuration
  51. #===============================================================================
  52. module TH
  53.   module Message_Skip
  54.    
  55.     # Switch to use to prevent message skipping
  56.     Disable_Switch = 0
  57.    
  58.     # Key to hold to skip messages
  59.     Skip_Key = :CTRL
  60.    
  61.     # Use "auto skip" mode. When the skip mode is OFF, you need to hold the
  62.     # skip key to fast-forward messages. When the skip mode is ON, you just
  63.     # need to press it once to begin skipping, and press it again to stop
  64.     # skipping
  65.     Auto_Skip = false
  66.    
  67.     # Ignore delays when skipping.
  68.     Skip_Delays = true
  69.     # Ignore pauses when skipping
  70.   end
  71. end
  72. #===============================================================================
  73. # ** Rest of script
  74. #===============================================================================
  75. class Window_Message < Window_Base
  76.    
  77.   def skip_key
  78.     TH::Message_Skip::Skip_Key
  79.   end
  80.  
  81.   def skip_key_pressed?
  82.     !$game_switches[TH::Message_Skip::Disable_Switch] && Input.press?(skip_key)
  83.   end
  84.  
  85.   #-----------------------------------------------------------------------------
  86.   # Overwrite. Actually all you really need is that extra line of code to tell
  87.   # the fiber to resume
  88.   #-----------------------------------------------------------------------------
  89.   def input_pause
  90.     self.pause = true
  91.     wait(10)
  92.     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || skip_key_pressed?
  93.     Input.update
  94.     self.pause = false
  95.   end
  96.  
  97.   alias :th_skip_message_wait :wait
  98.   def wait(duration)
  99.     return if TH::Message_Skip::Skip_Delays && skip_key_pressed?
  100.     th_skip_message_wait(duration)
  101.   end
  102.  
  103.   alias :th_wait_for_one_character :wait_for_one_character
  104.   def wait_for_one_character
  105.     update_show_fast
  106.     Fiber.yield unless @show_fast || @line_show_fast || (TH::Message_Skip::Skip_Delays && skip_key_pressed?)
  107.   end
  108. end
  109.  
  110. class Scene_Battle < Scene_Base
  111.  
  112.   def skip_key
  113.     TH::Message_Skip::Skip_Key
  114.   end
  115.  
  116.   def skip_key_pressed?
  117.     !$game_switches[TH::Message_Skip::Disable_Switch] && Input.press?(skip_key)
  118.   end
  119.  
  120.   alias :th_show_fast? :show_fast?
  121.   def show_fast?
  122.     Input.press?(:A) || Input.press?(:C) || (TH::Message_Skip::Skip_Delays && skip_key_pressed?)
  123.   end
  124.  
  125.   alias :th_wait_for_animation :wait_for_animation
  126.   def wait_for_animation
  127.     return if TH::Message_Skip::Skip_Delays && skip_key_pressed?
  128.     update_for_wait
  129.     update_for_wait while @spriteset.animation?
  130.   end
  131.  
  132.   alias :th_wait_for_effect :wait_for_effect
  133.   def wait_for_effect
  134.     return if TH::Message_Skip::Skip_Delays && skip_key_pressed?
  135.     update_for_wait
  136.     update_for_wait while @spriteset.effect?
  137.   end
  138. end
Advertisement
Add Comment
Please, Sign In to add comment