Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.
AInput Module Created by Alejandro Marzini (vgvgf) Version: 3.10 Last Updated: 19/08/2010 (day/month/year)
Description
This script adds input detection for all keyboard and mouse keys to the default input module. A mouse input plugin is also available. Compatible with RMXP & RMVX
New in version 3.10
General
Removed ALibrary dependencies
Renamed AWorks.dll to AInput.dll
Keyboard
Changed default repeat time to 4 (previously 2)
Added repeat_config, setup_dir, setup_wasd, setup_default and block_input
Previous Input functions are preserved, joystick input will work.
Mouse
Fixed mouse_in_area? and mouse_visible bugs
Added mouse_double_click_time=, mouse_double_click_pix= and mouse_drag_pix=
Keys
Fixed typos and renamed some keys
How to add to your project
Copy and paste the AIM.txt script and AKM.txt script before main in a new section.
If you want to use mouse input detection, add AIM-M.txt too.
Place AInput.dll in the project folder.
For how to use documentation, see the scripts comments.
Special Thanks
Poccil (Peter O.) for his methods for accessing ruby objects.
License
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Great job, vgvgf! But, what exactly is new/different between this version and the older version? Also, it looks like the Input/Keys module is now totally independant from the Aleworks libraries, such as Aleworks::API, does this mean that you no longer use/support the Aleworks::API module and other related libraries? Lastly, when you talk about how its "now faster than ever!" what exactly does that mean?
There was an issue I had with your older version, having to do with when a Print message was displayed on the window (with "p" or "print"). By default (without Aleworks), you can either close the print window by clicking the "OK" button on it, or by using a key like Enter (ie Input::C), without actually triggering an Input.trigger?(*) response. However, with Aleworks installed, the Input trigger now was triggered directly after closing the print window, causing accidental and undesired actions such as triggering scene changes in the Menu and the such. Is this something that has been resolved in the new version?
Lastly, what about your old addons, like the Name addon and the Password addon the one for Input Number? Do those still work with this version, or do you have to rescript those? (I always had a problem with Scene_Name not working but that might just be a personal problem in my project, or perhaps it conflicted with SDK maybe?) I appologize for bombarding you with questions, but I happened to utilize alot of your libraries functions in my scripts so there is alot I need to know about the new version.
Okay... I appologize, LAST QUESTION I promise...
Can your Input or Keys module detect the Mouse wheel scrolling up/down?
...Wierd ascii character Input? Why..? I don't even know how to do those weird characters, why would anybody use 'em?
Oh yeah, vgvgf, remember when I asked you about using Input in conditional branches (using events), how they don't work and you wrote that patch for me? You need to include that for eventers, because conditional branch input is only read if you use the Call Script vs normal event conventions again...
Code:
@> Conditonal Branch: The DOWN button is being pressed
 @> Play SE: '004-System04', '100', '100'
 @>
@>
...Doesn't do anything, you have to do...
Code:
@> Conditonal Branch: Script: Input.press?(Input::DOWN)
 @> Play SE: '004-System04', '100', '100'
 @>
@>
...Would have to be used. Here, incase you lost it I still have the old patch you did awhile back, I'm assuming it still works with this newer version I don't have time to test it right now but here, you wrote this a long time ago for me.
Code:
#=============================================================================
# *** Aleworks Input Module Compability Patch 1(AIM CP1)
#=============================================================================
# Created by Aleworks
# Version: 1.00
# Last Update: 29/03/2007 (day/month/year)
#=============================================================================
#==== Description ====
# This patch, is for making AIM, compatible with the default interpreter script
# of RPG Maker XP, when using the Conditional Branch and Button Input Processing
# commands.
#=============================================================================
#==== Requeriments ====
# * Aleworks Input Module
#Â Â - Version: 1.00 or superior
#=============================================================================
#==== Classes & Methods ====
# ** Class Interpreter
#Â Â * Overwrite Methods: input_button; command_111
#=============================================================================
#=============================================================================
# ** Interpreter
#=============================================================================
class Interpreter
 #---------------------------------------------------------------------------
 # * Input Button
 #---------------------------------------------------------------------------
 def input_button
  n = 1 if Input.trigger?(Input::LOWER_LEFT)
  n = 3 if Input.trigger?(Input::LOWER_RIGHT)
  n = 7 if Input.trigger?(Input::UPPER_LEFT)
  n = 9 if Input.trigger?(Input::UPPER_RIGHT)
  n = 2 if Input.trigger?(Input::DOWN)
  n = 4 if Input.trigger?(Input::LEFT)
  n = 6 if Input.trigger?(Input::RIGHT)
  n = 8 if Input.trigger?(Input::UP)
  n = 11 if Input.trigger?(Input::A)
  n = 12 if Input.trigger?(Input::B)
  n = 13 if Input.trigger?(Input::C)
  n = 14 if Input.trigger?(Input::X)
  n = 15 if Input.trigger?(Input::Y)
  n = 16 if Input.trigger?(Input::Z)
  n = 17 if Input.trigger?(Input::L)
  n = 18 if Input.trigger?(Input::R)
  if !n.nil?
   $game_variables[@button_input_variable_id] = n
   $game_map.need_refresh = true
   @button_input_variable_id = 0
  end
 end
 #---------------------------------------------------------------------------
 # * Conditional Branch
 #---------------------------------------------------------------------------
 def command_111
  result = false
  case @parameters[0]
  when 0
   result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
  when 1
   value1 = $game_variables[@parameters[1]]
   if @parameters[2] == 0
    value2 = @parameters[3]
   else
    value2 = $game_variables[@parameters[3]]
   end
   case @parameters[4]
   when 0
    result = (value1 == value2)
   when 1
    result = (value1 >= value2)
   when 2
    result = (value1 <= value2)
   when 3
    result = (value1 > value2)
   when 4
    result = (value1 < value2)
   when 5
    result = (value1 != value2)
   end
  when 2
   if @event_id > 0
    key = [$game_map.map_id, @event_id, @parameters[1]]
    if @parameters[2] == 0
     result = ($game_self_switches[key] == true)
    else
     result = ($game_self_switches[key] != true)
    end
   end
  when 3
   if $game_system.timer_working
    sec = $game_system.timer / Graphics.frame_rate
    if @parameters[2] == 0
     result = (sec >= @parameters[1])
    else
     result = (sec <= @parameters[1])
    end
   end
  when 4
   actor = $game_actors[@parameters[1]]
   if actor != nil
    case @parameters[2]
    when 0
     result = ($game_party.actors.include?(actor))
    when 1
     result = (actor.name == @parameters[3])
    when 2
     result = (actor.skill_learn?(@parameters[3]))
    when 3
     result = (actor.weapon_id == @parameters[3])
    when 4
     result = (actor.armor1_id == @parameters[3] or
          actor.armor2_id == @parameters[3] or
          actor.armor3_id == @parameters[3] or
          actor.armor4_id == @parameters[3])
    when 5
     result = (actor.state?(@parameters[3]))
    end
   end
  when 5
   enemy = $game_troop.enemies[@parameters[1]]
   if enemy != nil
    case @parameters[2]
    when 0
     result = (enemy.exist?)
    when 1
     result = (enemy.state?(@parameters[3]))
    end
   end
  when 6
   character = get_character(@parameters[1])
   if character != nil
    result = (character.direction == @parameters[2])
   end
  when 7
   if @parameters[2] == 0
    result = ($game_party.gold >= @parameters[1])
   else
    result = ($game_party.gold <= @parameters[1])
   end
  when 8
   result = ($game_party.item_number(@parameters[1]) > 0)
  when 9
   result = ($game_party.weapon_number(@parameters[1]) > 0)
  when 10
   result = ($game_party.armor_number(@parameters[1]) > 0)
  when 11
   n = Input::DOWN if @parameters[1] == 2
   n = Input::LEFT if @parameters[1] == 4
   n = Input::RIGHT if @parameters[1] == 6
   n = Input::UP if @parameters[1] == 8
   n = Input::A if @parameters[1] == 11
   n = Input::B if @parameters[1] == 12
   n = Input::C if @parameters[1] == 13
   n = Input::X if @parameters[1] == 14
   n = Input::Y if @parameters[1] == 15
   n = Input::Z if @parameters[1] == 16
   n = Input::L if @parameters[1] == 17
   n = Input::R if @parameters[1] == 18
   result = (Input.press?(n))
  when 12
   result = eval(@parameters[1])
  end
  @branch[@list[@index].indent] = result
  if @branch[@list[@index].indent] == true
   @branch.delete(@list[@index].indent)
   return true
  end
  return command_skip
 end
end
Also, I wrote this method-split for SDK which breaks up the Conditional Branch command (command_111), the current SDK doesn't use this yet but it'll probably come in the 2.5 version. Keep in mind, I highly doubt anybody would alter anything else within command_111 but I'll post it just incase. I also updated your "patch" with the new SDK branching I did.
Code:
#==============================================================================
# ** Enable Part II Check
#==============================================================================
if SDK::Parts.include?(2) ||
 SDK::Indidual_Parts.include?('INTERPRETER#COMMAND_111')
Â
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#Â This interpreter runs event commands. This class is used within the
#Â Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
 #--------------------------------------------------------------------------
 # * SDK Log Branch
 #--------------------------------------------------------------------------
 SDK.log_branch(:Interpreter, :command_111, :condition_switch,
 :condition_variable, :condition_local, :condition_timer, :condition_actor,
 :condition_enemy_state, :condition_facing, :condition_gold, :condition_items,
 :condition_weapons, :condition_armors, :condition_input, :condition_script)
 #---------------------------------------------------------------------------
 # * Conditional Branch
 #---------------------------------------------------------------------------
 def command_111
  result = false
  case @parameters[0]
  when 0 ; result = condition_switch
  when 1 ; result = condition_variable
  when 2 ; result = condition_local
  when 3 ; result = condition_timer
  when 4 ; result = condition_actor
  when 5 ; result = condition_enemy_state
  when 6 ; result = condition_facing
  when 7 ; result = condition_gold
  when 8 ; result = condition_items
  when 9 ; result = condition_weapons
  when 10 ; result = condition_armors
  when 11 ; result = condition_input
  when 12 ; result = condition_script
  end
  @branch[@list[@index].indent] = result
  if @branch[@list[@index].indent] == true
   @branch.delete(@list[@index].indent)
   return true
  end
  return command_skip
 end
 #-----------------------------------------------------------------------------
 # * Condition Switch
 #-----------------------------------------------------------------------------
 def condition_switch
  return ($game_switches[@parameters[1]] == (@parameters[2] == 0))
 end
 #-----------------------------------------------------------------------------
 # * Condition Variable
 #-----------------------------------------------------------------------------
 def condition_variable
  value1 = $game_variables[@parameters[1]]
  if @parameters[2].zero? ; value2 = @parameters[3]
  else          ; value2 = $game_variables[@parameters[3]]
  end
  case @parameters[4]
  when 0 ; return (value1 == value2)
  when 1 ; return (value1 >= value2)
  when 2 ; return (value1 <= value2)
  when 3 ; return (value1 > value2)
  when 4 ; return (value1 < value2)
  when 5 ; return (value1 != value2)
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Local
 #-----------------------------------------------------------------------------
 def condition_local
  if @event_id > 0
   key = [$game_map.map_id, @event_id, @parameters[1]]
   if @parameters[2].zero? ; return ($game_self_switches[key] == true)
   else          ; return ($game_self_switches[key] != true)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Timer
 #-----------------------------------------------------------------------------
 def condition_timer
  if $game_system.timer_working
   sec = $game_system.timer / Graphics.frame_rate
   if @parameters[2].zero? ; return (sec >= @parameters[1])
   else          ; return (sec <= @parameters[1])
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Actor
 #-----------------------------------------------------------------------------
 def condition_actor
  actor = $game_actors[@parameters[1]]
  unless actor.nil?
   case @parameters[2]
   when 0 ; return ($game_party.actors.include?(actor))
   when 1 ; return (actor.name == @parameters[3])
   when 2 ; return (actor.skill_learn?(@parameters[3]))
   when 3 ; return (actor.weapon_id == @parameters[3])
   when 4 ; return (actor.armor1_id == @parameters[3] or
         actor.armor2_id == @parameters[3] or
         actor.armor3_id == @parameters[3] or
         actor.armor4_id == @parameters[3])
   when 5 ; return (actor.state?(@parameters[3]))
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Enemy State
 #-----------------------------------------------------------------------------
 def condition_enemy_state
  enemy = $game_troop.enemies[@parameters[1]]
  unless enemy.nil?
   case @parameters[2]
   when 0 ; return (enemy.exist?)
   when 1 ; return (enemy.state?(@parameters[3]))
   end
  end Â
 end
 #-----------------------------------------------------------------------------
 # * Condition Facing
 #-----------------------------------------------------------------------------
 def condition_facing
  character = get_character(@parameters[1])
  unless character.nil?
   return (character.direction == @parameters[2])
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Gold
 #-----------------------------------------------------------------------------
 def condition_gold
  if @parameters[2].zero? ; return ($game_party.gold >= @parameters[1])
  else          ; return ($game_party.gold <= @parameters[1])
  end Â
 end
 #-----------------------------------------------------------------------------
 # * Condition Items
 #-----------------------------------------------------------------------------
 def condition_items
  return ($game_party.item_number(@parameters[1]) > 0)
 end
 #-----------------------------------------------------------------------------
 # * Condition Weapons
 #-----------------------------------------------------------------------------
 def condition_weapons
  return ($game_party.weapon_number(@parameters[1]) > 0)
 end
 #-----------------------------------------------------------------------------
 # * Condition Armors
 #-----------------------------------------------------------------------------
 def condition_armors
  return ($game_party.armor_number(@parameters[1]) > 0)
 end
 #-----------------------------------------------------------------------------
 # * Condition Input
 #-----------------------------------------------------------------------------
 def condition_input
  return (Input.press?(@parameters[1]))
 end
 #-----------------------------------------------------------------------------
 # * Condition Script
 #-----------------------------------------------------------------------------
 def condition_script
  return eval(@parameters[1]).nil? ? false : eval(@parameters[1])
 end
end
#==============================================================================
# ** Ends Enable Part II Check
#==============================================================================
end
Code:
#=============================================================================
# *** Aleworks Input Module Compability Patch 1(AIM CP1)
#=============================================================================
# Created by Aleworks
# Version: 1.00
# Last Update: 29/03/2007 (day/month/year)
#=============================================================================
#==== Description ====
# This patch, is for making AIM, compatible with the default interpreter script
# of RPG Maker XP, when using the Conditional Branch and Button Input Processing
# commands.
#=============================================================================
#==== Requeriments ====
# * Aleworks Input Module
#Â Â - Version: 1.00 or superior
# * Standard Development Kit
# - Version : 2.50 or superior
#=============================================================================
#==== Classes & Methods ====
# ** Class Interpreter (SDK)
#Â Â * Overwrite Methods: condition_input
#=============================================================================
#-----------------------------------------------------------------------------
# * SDK Log
#-----------------------------------------------------------------------------
SDK.log('Aleworks Input Interpreter', 'vgvgf+Kain Nobel', 1.01, '2007-27-08')
SDK.log_overwrite(Interpreter, :condition_input)
#-----------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-----------------------------------------------------------------------------
if SDK.enabled?('Aleworks Input Interpreter')
#=============================================================================
# ** Interpreter
#=============================================================================
class Interpreter
 #---------------------------------------------------------------------------
 # * Input Button
 #---------------------------------------------------------------------------
 def input_button
  n = 1 if Input.trigger?(Input::LOWER_LEFT)
  n = 3 if Input.trigger?(Input::LOWER_RIGHT)
  n = 7 if Input.trigger?(Input::UPPER_LEFT)
  n = 9 if Input.trigger?(Input::UPPER_RIGHT)
  n = 2 if Input.trigger?(Input::DOWN)
  n = 4 if Input.trigger?(Input::LEFT)
  n = 6 if Input.trigger?(Input::RIGHT)
  n = 8 if Input.trigger?(Input::UP)
  n = 11 if Input.trigger?(Input::A)
  n = 12 if Input.trigger?(Input::B)
  n = 13 if Input.trigger?(Input::C)
  n = 14 if Input.trigger?(Input::X)
  n = 15 if Input.trigger?(Input::Y)
  n = 16 if Input.trigger?(Input::Z)
  n = 17 if Input.trigger?(Input::L)
  n = 18 if Input.trigger?(Input::R)
  if !n.nil?
   $game_variables[@button_input_variable_id] = n
   $game_map.need_refresh = true
   @button_input_variable_id = 0
  end
 end
 #-----------------------------------------------------------------------------
 # * Condition Input
 #-----------------------------------------------------------------------------
 def condition_input
  n = Input::DOWN if @parameters[1] == 2
  n = Input::LEFT if @parameters[1] == 4
  n = Input::RIGHT if @parameters[1] == 6
  n = Input::UP if @parameters[1] == 8
  n = Input::A if @parameters[1] == 11
  n = Input::B if @parameters[1] == 12
  n = Input::C if @parameters[1] == 13
  n = Input::X if @parameters[1] == 14
  n = Input::Y if @parameters[1] == 15
  n = Input::Z if @parameters[1] == 16
  n = Input::L if @parameters[1] == 17
  n = Input::R if @parameters[1] == 18
  return (Input.press?(n))
 end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
After testing the Print command VS Input::C triggering afterwards, its slightly better. If I release Enter/C or whatever quick enough, the key doesn't trigger in-game (just like its supposed to not do), but... its not supposed to trigger at all if you're still holding an Input::C key until you press it again. I'm not sure how you'd fix this, maybe I'll figure out how and post it. But basically, you might need to use some API magic to see if the Game's main window is active, or if another window (such as the Print window) is active, and clear the trigger if so, or set some kinda flag.
Other than that, great improvement, I think I see what you mean now by "faster". In the old version, I don't think the key would clear right away after I released it, this one responds a little bit better to real-time pushing and releasing.
Great job, vgvgf! But, what exactly is new/different between this version and the older version? Also, it looks like the Input/Keys module is now totally independant from the Aleworks libraries, such as Aleworks::API, does this mean that you no longer use/support the Aleworks::API module and other related libraries? Lastly, when you talk about how its "now faster than ever!" what exactly does that mean?
Thanks. The difference is that now it uses a DLL for updating the input states, so all the update methods are now in c which is really faster than ruby. Also, I forgot to say that the script was in BETA version, and temporaly I have removed the dependency of Aleworks Library, because I am rewriting it in a better way. Also I am doing the same with all my scripts and some new.
There was an issue I had with your older version, having to do with when a Print message was displayed on the window (with "p" or "print"). By default (without Aleworks), you can either close the print window by clicking the "OK" button on it, or by using a key like Enter (ie Input::C), without actually triggering an Input.trigger?(*) response. However, with Aleworks installed, the Input trigger now was triggered directly after closing the print window, causing accidental and undesired actions such as triggering scene changes in the Menu and the such. Is this something that has been resolved in the new version?
I have never realised of that, but I will see what can I do.
Lastly, what about your old addons, like the Name addon and the Password addon the one for Input Number? Do those still work with this version, or do you have to rescript those? (I always had a problem with Scene_Name not working but that might just be a personal problem in my project, or perhaps it conflicted with SDK maybe?) I appologize for bombarding you with questions, but I happened to utilize alot of your libraries functions in my scripts so there is alot I need to know about the new version.
After testing the Print command VS Input::C triggering afterwards, its slightly better. If I release Enter/C or whatever quick enough, the key doesn't trigger in-game (just like its supposed to not do), but... its not supposed to trigger at all if you're still holding an Input::C key until you press it again. I'm not sure how you'd fix this, maybe I'll figure out how and post it. But basically, you might need to use some API magic to see if the Game's main window is active, or if another window (such as the Print window) is active, and clear the trigger if so, or set some kinda flag.
I tested all Keyboard and mouse input, but I never found a value which corresponds to wheel scrolling...
It's because it's another system ?
Because the wheel has been implemented after keyboard and mouse without wheel on computers ?
Thanks, I will see how can I convert this to C for DLL, or something better if I can find something so.
Code:
Using Winapi is very slow... I know people, when they use my scripts, they have 7 FPS.
I delete the use of keyboard, and they have more than 37 FPS.
I don't have test the vgvgf's script. I hope it will be faster. ;)
Yeah, but my script runs as fast as the original one, or at maximum 1 FPS less.
Now I have done the release version of the script, not more in beta version, and now it comes with a Mouse Plugin for mouse input detection. Also, I have added some demos for XP and VX of the script.
Well, I don't know what APD is, it works with qwerty keyboards and should with azerty, too, and also it should work with all keyboards layouts, as the Virtual keys corresponding to each key are the same except for the OEM keys/characters. Also, I am still working on the writing system, aka getting the real character for the user keyboard and configuration. However, I still don't know when I will finish it.
The error will be fixed in the next version. I thought that I have already fixed it in this new version, I it seems I have forgotten it.
1.
the APD is a script manage system (like the sdk) but its for both, and has more intresting functions
2. im also work on a writing system ... (because i need it for my save)
PS: how can a mark a thead that i get email if it change?