02-16-2012, 02:47 PM 
	
	
	
		Not only did I need a few tweaks and addons for game controls, I needed to refresh myself on scripting, so I've written the following today....
  			
  			
  			
  			
  			
This is a milestone to me haha! I used to only be able to script while drunk, I quit drinking back in 2009 and haven't been able to script since... until tonight! I feel empowered, like I can finally take all my different talents and invoke them to do my deeds :D
	
	
	 Input : Convert
  			This is inspired by VX Ace. Instead of having to do Input.trigger?(Input::C) you can do Input.trigger?(:C) (if you want.)
		Code:
#===============================================================================
# ** Input
#===============================================================================
#-------------------------------------------------------------------------------
# * Conversion Symbols
#-------------------------------------------------------------------------------
Input::Convert = [:A, :B, :C, :X, :Y, :Z, :L, :R, :UP, :DOWN, :LEFT, :RIGHT]
class << Input
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :convert_input_trigger?, :trigger?
  alias_method :convert_input_repeat?,  :repeat?
  alias_method :convert_input_press?,   :press?
  #-----------------------------------------------------------------------------
  # * Input.trigger?(input)
  #-----------------------------------------------------------------------------
  def trigger?(input)
    # The usual, auto-convert if needed
    convert_input_trigger?(convert(input))
  end
  #-----------------------------------------------------------------------------
  # * Input.repeat?(input)
  #-----------------------------------------------------------------------------
  def repeat?(input)
    # The usual, auto-convert if needed
    convert_input_repeat?(convert(input))
  end
  #-----------------------------------------------------------------------------
  # * Input.press?(input)
  #-----------------------------------------------------------------------------
  def press?(input)
    # The usual, auto-convert if needed
    convert_input_press?(convert(input))
  end
  #-----------------------------------------------------------------------------
  # * Input.convert(input)
  #-----------------------------------------------------------------------------
  def convert(n)
    # Auto convert if symbol
    (n.is_a?(Symbol) ? n.to_input : n)
  end
end
#===============================================================================
# ** Symbol
#===============================================================================
class Symbol
  #-----------------------------------------------------------------------------
  # * To Input
  #-----------------------------------------------------------------------------
  def to_input
    # Return nil unless this symbol is in the input list
    return nil unless Input::Convert.includes?(self)
    # Convert to input object
    Input.const_get(self)
  end
end Input : Combo
  			This is very early WIP, I already have plans on re-crafting this majorly tomorrow. Anyways, I needed a key sequencing script. We'll use Ryu's Hyduken as an example of what this does,,,.
![[Image: %5BInput%5D-PS3-D2%20(Down).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D2%20(Down).png) ,
,![[Image: %5BInput%5D-PS3-D3%20(Down+Right).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D3%20(Down+Right).png) ,
,![[Image: %5BInput%5D-PS3-D6%20(Right).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D6%20(Right).png) +
+![[Image: %5BInput%5D-PS3-A%20(Square).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-A%20(Square).png)
		![[Image: %5BInput%5D-PS3-D2%20(Down).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D2%20(Down).png) ,
,![[Image: %5BInput%5D-PS3-D3%20(Down+Right).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D3%20(Down+Right).png) ,
,![[Image: %5BInput%5D-PS3-D6%20(Right).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-D6%20(Right).png) +
+![[Image: %5BInput%5D-PS3-A%20(Square).png]](http://bb.ohsk.net/uploads/%5BInput%5D-PS3-A%20(Square).png)
Code:
#===============================================================================
# ** InputCombo
#===============================================================================
class InputCombo
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :first_key    # Matches first key before recording input
  attr_accessor :auto_reset   # Object is automatically reset when successful
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize(time, *keys)
    @first_key  = true
    @auto_reset = true
    # Set goal time and keys
    @set_time   = time
    @set_keys   = keys
    # Reset player's time/keys
    reset
  end
  #-----------------------------------------------------------------------------
  # * Reset
  #-----------------------------------------------------------------------------
  def reset
    # Create a new array for keys if one doesn't exist
    @keys ||= Array.new
    # Set time to 0 and empty keys
    @time = 0
    @keys.clear
  end
  #-----------------------------------------------------------------------------
  # * Time Limit Reached?
  #-----------------------------------------------------------------------------
  def time_limit_reached?
    # False if set time is less than one frame
    return false if @set_time < 1
    # True if player's time equals or exceeds time limit
    @time >= @set_time
  end
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update
    # End method if keys matched
    return if self.true?
    # End method if time limit reached
    return if self.time_limit_reached?
    # Add one to player's time unless player hasn't matched a key yet
    @time += 1 unless @first_key && @keys.empty?
    # Iterate through input
    Input::Convert.each do |input|
      # If this input key was triggered
      if Input.trigger?(input)
        # If first key flag and player hasn't hit any correct keys
        if @first_key && @keys.empty?
          # Break iteration unless key matches first in set
          break unless input == @set_keys[0]
        end    
        # Add key to player's key list
        @keys << input
        # Break iteration
        break
      end
    end
  end
  #-----------------------------------------------------------------------------
  # * True?
  #-----------------------------------------------------------------------------
  def true?
    # True if keys matched
    @keys == @set_keys
  end
end
#===============================================================================
# ** Scene_Map (Testing purposes)
#===============================================================================
class Scene_Map
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :testcombo_scnmap_main,    :main
  alias_method :testcombo_scnmap_update,  :update
  #-----------------------------------------------------------------------------
  # * Main
  #-----------------------------------------------------------------------------
  def main
    # Press C three times within approx 10 seconds (400 frames)
    @combo = InputCombo.new(400, :L, :R, :L, :R)
    # The usual
    testcombo_scnmap_main
  end
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update
    # Update combo object
    @combo.update unless Object.const_defined?(:SDK)
    # If combo sequence entered
    if @combo.true?
      # Print message
      p 'Button combination L, R, L, R successfully entered!'
      # Reset combo
      @combo.reset
    end
    # The usual
    testcombo_scnmap_update
  end
end Input : Menu
  			This was more or less an exercise to see if I could alias the functionality of changing an input key without the simple ONE letter overwrite on Scene_Map line 123 haha. Hey, I haven't scripted for awhile, so I needed the challenge.
		Code:
#===============================================================================
# ** Input
#===============================================================================
class << Input
  #-----------------------------------------------------------------------------
  # * Class Variable Declaration
  #-----------------------------------------------------------------------------
  @@menu  = Input::X
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :input2menu_input_trigger?, :trigger?
  #-----------------------------------------------------------------------------
  # * Input.trigger?
  #-----------------------------------------------------------------------------
  def trigger?(input)
# Change input key if calling menu
input = @@menu if trigger_menu?(input)
# The usual
input2menu_input_trigger?(input)
  end
  #-----------------------------------------------------------------------------
  # * Input.trigger_menu?
  #-----------------------------------------------------------------------------
  def trigger_menu?(input)
# False unless scene is map
return false unless $scene.is_a?(Scene_Map)
# False unless checking for B button
return false unless input == Input::B
# True if menu calling
$game_temp.input2menu
  end
end
#===============================================================================
# ** Game_Temp
#===============================================================================
class Game_Temp
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :input2menu                # Flag for menu button
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :input2menu_gmtemp_initialize, :initialize
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize(*args)
# The usual
input2menu_gmtemp_initialize(*args)
# Default to false
@input2menu = false
  end
end
#===============================================================================
# ** Scene_Map
#===============================================================================
class Scene_Map
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :input2menu_scnmap_update, :update
  #-----------------------------------------------------------------------------
  # * Frame Update : Menu Call
  #-----------------------------------------------------------------------------
  def update
# Set flag for custom menu button
$game_temp.input2menu = true
# The usual
input2menu_scnmap_update
# Disable flag for custom menu button
$game_temp.input2menu = false
  end
end Input : Full Screen
  			F7 for one button fullscreen.
		Code:
#===============================================================================
# ** Input : Full Screen
#===============================================================================
class << Input
  #-----------------------------------------------------------------------------
  # * Class Variable Declaration
  #-----------------------------------------------------------------------------
  @@fullscreen = Input::F7
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :input2fullscreen_input_update, :update
  #-----------------------------------------------------------------------------
  # * Input.update
  #-----------------------------------------------------------------------------
  def update(*args)
# The usual
input2fullscreen_input_update(*args)
# If fullscreen button is triggered
if self.trigger?(@@fullscreen)
  # Set keyboard event (if nil)
  @_keybd_event ||= Win32API.new('user32', 'keybd_event', 'LLLL', '')
  # Call full screen inputs
  @_keybd_event.call(18,0,0,0)
  @_keybd_event.call(13,0,0,0)
  @_keybd_event.call(13,0,2,0)
  @_keybd_event.call(18,0,2,0)
  # Reset frames to prevent lag
  Graphics.frame_reset
  # End method
  return
end
  end
end Input : Shutdown
  			F8 for one button shutdown. This script will be enhanced to do a quick-save when you shut the game down, and re-load the saved file immediately in the next game's session.
		Code:
#===============================================================================
# ** Input : Shutdown
#===============================================================================
class << Input
  #-----------------------------------------------------------------------------
  # * Class Variable Declaration
  #-----------------------------------------------------------------------------
  @@shutdown = Input::F8
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :input2shutdown_input_update, :update
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update(*args)
# The usual
input2shutdown_input_update(*args)
# If shutdown key is currently being pressed
if self.press?(@@shutdown)
  # Call the shutdown method
  Scene_End.new.command_shutdown
  # End method
  return
end
  end
endThis is a milestone to me haha! I used to only be able to script while drunk, I quit drinking back in 2009 and haven't been able to script since... until tonight! I feel empowered, like I can finally take all my different talents and invoke them to do my deeds :D

 
 
 What's up, RMers?
 What's up, RMers?
 
 
![[Image: Button-BOTB.png]](https://i.postimg.cc/tTyHps78/Button-BOTB.png)
![[Image: Save-Point.gif]](https://i.postimg.cc/26znDy3v/Save-Point.gif)
![[Image: Button-You-Tube2.png]](https://i.postimg.cc/MphKJF38/Button-You-Tube2.png)
![[Image: Button-Sound-Cloud2.png]](https://i.postimg.cc/cLK4jSmm/Button-Sound-Cloud2.png)
![[Image: Button-Audio-Mack2.png]](https://i.postimg.cc/0Q8zw08x/Button-Audio-Mack2.png)
![[Image: LS-Banner.gif]](https://i.postimg.cc/9MRtf4jm/LS-Banner.gif)