Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Heretic86

[XP][VX][VXA] Timed User Input - Lite Version

Recommended Posts

Timed User Input - Lite Version

Authors: Diagostimo, Heretic

Version: 1.0

Type: Simulated User Input


Introduction

 

This Script is intended to allow you to Simulate User Input in ANY Scene at ANY time by entering a series of simple script commands.


Features

 


  • [li]Simulate User Input at specific times[/li]
    [li]Very easy to use[/li]
    [li]Highly Compatible[/li]
    [li]I like shiny things[/li]


Screenshots

 

No Screenshots.

 

It isnt possible to take a Screenshot of simulating User Input.


Demo

 

This Demo contains a FULL VERSION of the script with expandad functionality.

 

http://www.775.net/~heretic/downloads/rmxp/AnimatedTitleScreen/index.php


Script

 

This is the LITE VERSION of the User Input Script. It does NOT contain the expanded functionality provided by the FULL VERSION, but will be more compatible.

 

Place above Main.

 

#===============================================================================
#
#		   Timed User Input
#		   Authors: Diagostimo, Heretic
#		   Version 1.0
#		   Saturday, November 9th, 2012
#
#===============================================================================
#
# This script is the work of Diagostimo and Heretic
#
# Keys can be entered either by saying B or C instead of Input::B or Input::C
# This works for directions also: DOWN or UP instead of Input::DOWN or Input::UP
#
# ALWAYS USE ALL CAPITAL LETTERS FOR YOUR KEYS!
#
# There are two ways to use this script.
#
#  1: Single Keypress
#  In an Event, run a Script:
#  Input.change_key(Key)
#
#  * Most useful when used in Parallel or Autorun processes
#
#
#  2: Automated Keypress
#  In an Event, run a Script:
#  timed_input(wait, keys)
#  
#  - Examples -
#
#  timed_input(20, C)	    Effect: Waits 20 frames, then simulates the C Key
#  timed_input(14, DOWN, C)  Effect: Waits 14 frames, and simulates DOWN and C
#  timed_input(40)		   Effect: This just waits.  May sometimes be useful.
#
#  NOTE: Build your Input Sequences BEFORE bringing up any Menus
#
#  NOTE: Use "Call Menu Screen" on Page 3 of Event Commands instead of trying
#	    to use "B" to bring up the Menu.  It wont work because an Event is
#	    doing its thing.
#
#  NOTE: You cant use this script to simulate Player Movement, the same way
#	    as you are unable to move (by default) while an Event is processing.
#
#
#  This Script is a simlified version of Timed User Input, Scripts, and Windows.
#
#  It lacks the expanded functionality of the other version of the script, but
#  will be more compatible.  It works a bit differently as well, but may be
#  easier to use with Custom Battle System Menus due to the differences.
#
#  --- TIMING DIFFERENCES in XP and VX / Ace ---
#
#  The Timing in XP and VX / VX Ace is a bit different.
#
#  In XP, 1 second is 20 Frames, and usually runs at 40 Frames Per Second so
#  value is multiplied by two
#
#  In VX and VX Ace, 1 second is 60 Frames Per Second and isnt multiplied
#
#
#  ---  LEGAL STUFF  ---
#
#  Legal: This script is not my property and is used with permission
#  from diagostimo.  It has been modified by Heretic to be easier to use.

module Input_Constants
 DOWN = Input::DOWN
 LEFT = Input::LEFT
 RIGHT = Input::RIGHT
 UP = Input::UP
 A = Input::A
 B = Input::B
 C = Input::C
 X = Input::X
 Y = Input::Y
 Z = Input::Z
 L = Input::L
 R = Input::R
end

module RPG
 # Timing for XP and VX is different, 20 FPS is 1 second in XP 60 in VX and Ace
 Input_Time_Multiplier = defined?(Game_Interpreter) ? 1 : 2
 # Create New Class
 class TimedInput
   # Mixed Variable and Array types are easier as Objects
   def initialize(wait, parameters = [])
  # Time to wait before simulating keystrokes	  
  @wait = wait * Input_Time_Multiplier
  # The Input Keys to be Simulated - Handles Multiple Keys
  @parameters = parameters
   end
   attr_accessor :wait
   attr_accessor :parameters
 end
end

# Interpreter is named differently in VX and XP
Intepreter_Name = defined?(Game_Interpreter) ? Game_Interpreter : Interpreter

class Intepreter_Name
 include Input_Constants
 def timed_input(wait, *keys)
   Input.change_auto_keys(RPG::TimedInput.new(wait, keys))
 end
 def clear_auto
   Input.init
 end
end

class Game_Character
 include Input_Constants  
 def timed_input(wait, *keys)
   Input.change_auto_keys(RPG::TimedInput.new(wait, keys))
 end
 def clear_auto
   Input.init
 end
end

module Input
 # If class is already defined - F12 Reset
 if $input_class_defined
   # Reset associated variables defined in def init
   init
 else
   # Store Global Variable that modifications to input class have been defined
   $input_class_defined = true  
   class << self
  #alias listing
  alias update_forced update
  alias trigger_forced trigger?
  alias press_forced press?
  alias repeat_forced repeat?
  alias dir4_forced dir4
  alias dir8_forced dir8

  #initialize
  def init
    @forced = nil
    @auto_forced = []
    @auto_index = 0
    @auto_timer = 0
    @auto_input_time = false
    @input_forced = false
    @input_disabled = false
  end

  def change_input_flag
    @auto_input_time = true
  end

  #change forced value
  def change_key(key)
    @forced = key
  end

  #change auto forced keys
  def change_auto_keys(object)
    @auto_forced.push(object)
    @auto_timer = @auto_forced[0].wait
    @auto_input_time = true
    @input_disabled = true	  
  end

  #modified Input.update method
  def update
    if @auto_input_time
	  if @auto_timer == 0
	    if @auto_index == @auto_forced.size - 1
		  @auto_index = 0
		  @auto_input_time = false
		  @input_disabled = false			  
		  @auto_forced = []
	    elsif @auto_forced.size > 0
		  @auto_index += 1
		  @auto_timer = @auto_forced[@auto_index].wait
		  return
	    end
	  end
	  @auto_timer -= 1 if @auto_timer > 0
    end
    @forced = nil
    @input_forced = false
    # Original Input.update method
    update_forced
  end

  # called by press?, trigger? and repeat?
  def auto_forced?(key)
    if @auto_input_time && @auto_timer == 0 && @auto_forced.size > 0
	  # auto_group is an Array of Keys that when checked return true
	  auto_group = @auto_forced[@auto_index].parameters

	  (0...auto_group.size).each {|i|
	    if auto_group[i] == key
		  @input_forced = true
		  return true
	    end
	  }
    end
    return false
  end

 # these return true if input check is forced
  def trigger?(key)
    return true if auto_forced?(key) or @forced == key
    return false if @input_disabled
    trigger_forced(key)
  end

  def press?(key)
    return true if auto_forced?(key) or @forced == key
    return false if @input_disabled
    press_forced(key)
  end

  def repeat?(key)
    return true if auto_forced?(key) or @forced == key
    return false if @input_disabled
    repeat_forced(key)
  end

  def dir4
    dir = dir4_forced
    return dir if auto_forced?(dir) or @forced == dir
    return 0 if @input_disabled
    return dir
  end

  def dir8
    dir = dir8_forced
    return dir if auto_forced?(dir) or @forced == dir
    return 0 if @input_disabled
    return dir
  end

  def input_forced?
    return true if @input_forced or @forced
  end
   end
 end
end
#calling the initialize method
Input.init

 


Instructions

 

How to use:

 

timed_input(wait=n, key)

 

Wait is Wait Time in Frames before simulating the key as the Button pressed.

 

Key is a CAPITAL LETTER of the corresponding Input Key or WORD. That means you dont need to put in Input::DOWN, you can just put in the word DOWN in all capital letters.

 

See Script and Demo for examples.


Compatibility

 

I believe this will be nearly 100% compatible with other Scripts, including other Input Scripts! If there are any compatability issues, please let me know and I'll do my best to correct them.


Credits and Thanks

 


  • [li]Diagostimo for providing the original code that was expanded on.[/li]
    [li]I'd like to thank the Academy...[/li]


Author's Notes

 

My goal with this script is to reach as close to a 100% compatability rating as I can get.

 

NOTE: There are TWO VERSIONS of this Script. This is the LITE VERSION. Both versions are very similar, but for sake of compatability, a LITE VERSION was born. Some of the features in the Full Version may not be needed at all, but they may also lower the compatability.

 

The Lite Version is compatible with RMXP, RMVX, and RMVXA.

 

Update: Minor update to fix compatability with VX and Ace. Verified as compatible in all versions.

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

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...