Aleworks Input Module - Version 2.01

Aleworks Input Module
Created by Aleworks (vgvgf)
Version: 2.02
Last Updated: 13/09/2007(day/month/year)


Introduction
This script simulates the RGSS module "Input". It is not the original module, but it has all the original module functions and some new.

Version History Spoiler
* Version 1.00[INDENT] - New methods: Input.reiterate?; Input.activated?; Input.press_all; Input.trigger_all; Input.repeat_all; Input.reiterate_all
- New Keys: LOWER_LEFT; LOWER_RIGHT; UPPER_LEFT; UPPER_RIGHT
[/INDENT] * Version 1.10
[INDENT] - New methods: Input.event; Input.free_key; Input.free_all_keys
[/INDENT] * Version 1.11[INDENT] - Changed the variables: @repeat_time, @reiterate_time, @reiterate and @update_keys to global variables for easy editing.
[/INDENT] * Version 1.12(Now in Aleworks Input Module Compability Patch 1)
[INDENT] - Compability with the event commands: Asing Key and Condition Branch
[/INDENT] * Version 1.20[INDENT] - Little lag reduction
- New methods: Input.release?; Input.release_all
[/INDENT] * Version 1.21
[INDENT] - Major bug fixed, when using arrays in Input.press?, Input.trigger?, Input.reiterate? and Input.release?
- Removed $update_keys and $reiterate
[/INDENT] * Version 2.00
[INDENT] - Little lag reduction
- Rewrited some code
- No more need of Win32::Registry, but need Aleworks Library
- Key Combos[INDENT] - New Class: Input::Key_Combo[INDENT] - New Methods: Input.add_combo; Input.combo; Input.combos; Input.combos; Input.delete_combo; Input.delete_ended_combos
[/INDENT][/INDENT] - Mouse Input[INDENT] - New Methods: Input.mouse_double_click?; Input.mouse_x?; Input.mouse_y?; Input.mouse_dragging?; Input.mouse_drag_rect?; Input.mouse_drag_coor?
- New Constants: MOUSE_INPUT; MOUSE_DOUBLE_CLICK_TIME; MOUSE_DOUBLE_CLICK_PIX; MOUSE_DRAG_PIX; MOUSE_PRIMARY; MOUSE_SECONDARY
[/INDENT][/INDENT]* Version 2.01
[INDENT]- Input.mouse_x? and Input.mouse_y? will now return nil if the mouse poiter is out of the game screen.
[/INDENT]* Version 2.02
[INDENT]- Fixed error in Input.press?.
[/INDENT]
Script
Aleworks Input Module Script Pack 2.1


* Please give me credit if you use my script.
* Help me to continue developing this script, send the errors that you find and your ideas to [email hidden]
And.... What has changed?
He made some methods like Press all keys and also you can tell if the Numlock or capitials is on which is pretty cool.

I'll switch to this Input Method for N+ if it doesn't cause any problems.
You post very formally, VGVGF.. :)

Nice script this is... :D
Quote:
And.... What has changed?
Oburi, the other Input modules(or keyboard modules) does not have the repeat method, and the trigger method does not work well. My script works like the original RGSS Input module and has some new methods:
Input.reiterate?(num)
Input.activated?(num)
Input.press_all
Input.trigger_all
Input.repeat_all
Input.reiterate_all

And it reads the RMXP registry for the buttons A,B,C,X,Y,Z,L and R, that are configurated with F1 in the game.

For more info see the script.


I have updated the script to version 1.12, see first post.
^^Very Nice Indeed, I think I will start using this one... Good Work!
I make a new version of the script, the 1.20.

New things:
* Little lag reduction
* Input.release?(num)
Returns true if the key num has been released.
* Input.release_all
Returns the keys that has been released.
I have seen this script on dubealex', it's great, vgvgf (would like to know what it stands for, randomly triggered?)
Like to see more of your scripts.
keep it up, pro
Caldaron
I have upadted the script to version 1.21.
Version updates:
* Major bug fixed, when using arrays in Input.press?, Input.trigger?,
Input.reiterate? and Input.release?
* Removed $update_keys and $reiterate

[QUOTE=Caldaron;143206](would like to know what it stands for, randomly triggered?)[/QUOTE]
What is "stands for"? I don't know what this significates. My english is not complete...
[QUOTE=vgvgf;144749]What is "stands for"? I don't know what this significates. My english is not complete...[/QUOTE]He's asking you what is the meaning of "vgvgf". :yes:
I don't know why, but your script started working strange for me. Although it used to work just great, now for the first seconds of the game it keeps behaving like I have all the keyboard keys pressed. This happens in untouched version of your demo, too. For everyone experiencing same problems, I figured it out that putting "Input.update" above the main loop in MAIN seems to fix this.
Quote:
I don't know why, but your script started working strange for me. Although it used to work just great, now for the first seconds of the game it keeps behaving like I have all the keyboard keys pressed. This happens in untouched version of your demo, too. For everyone experiencing same problems, I figured it out that putting "Input.update" above the main loop in MAIN seems to fix this.

That's rare, I will try to see what make that error. However, I am making a new version of the script that will be much better.
Weeks of work and now I can release version 2.00. Now with Mouse Input and Key Combos(Explained in script). See first post.
hum... the link seems to be dead :S
this new version seems good.

What about international keyboard support, to detect the correct character to input?

EDIT: the link is not dead... seems it was me..
Quote:
What about international keyboard support, to detect the correct character to input?

Already done. See the new beta of Aleworks Write. Link in my signature.
a little suggestion :
To create a Input.Mouse_over?(object) would be great :p ( basically check if the cursor is inside the object rectangle :p
I dont understand whats this for
By the way, you know, Page Up & Page Down normally act as L/R button. However, with this script, only keys which set as L/R button(via F1 config) work.(You won't see Page Up/Down work as L/R button)
Quote:
I dont understand whats this for

Sorry for being late. This script allows you to check all keys of the keyboard if are pressed, trigered, repeated, released, or reiterated, check mouse position, and lots more.

Quote:
By the way, you know, Page Up & Page Down normally act as L/R button. However, with this script, only keys which set as L/R button(via F1 config) work.(You won't see Page Up/Down work as L/R button)

I did not know about that, but now yes. In the next version, that will be fixed.
Thanks.
There is an error with how this script handles the mouse position. If you use Input.mouse_x? or Input.mouse_y? when the mouse moves outside of the window, an error pops up. Depending on how you use it, you may either get a NilClass error, or cannot convert nil into a array or something to that effect. I have found a solution. If @mouse.pos is nil, just return -1. Like so:
  #---------------------------------------------------------------------------
  # * Mouse X Coordinate
  #---------------------------------------------------------------------------
  def Input.mouse_x?
    unless @mouse_pos == nil
      @mouse_pos[0]
    else
      return -1
    end
  end
  #---------------------------------------------------------------------------
  # * Mouse Y Coordinate
  #---------------------------------------------------------------------------
  def Input.mouse_y?
    unless @mouse_pos == nil
      @mouse_pos[1]
    else
      return -1
    end
  end
Expand to see the code.
Thanks DraycosGoldaryn for the bug report, but I have already seen it, and it is not the unique error of the mouse handle. I will release a new fixed version of AIM, but first I need to update Aleworks Library that have some errors in the mouse APIs.
Some fixes in mouse input.
Er....... By the way, I think another problem happened. I cannot move character unless Numlock is on.(In menu or any other scene, arrow keys work normally)
I have the same problem, but I cannot move my character with the normal arrow keys. Only with the numpad keys (when NumLock is turned on)
That's bad... I will chack that, and maybe I will be realising the 2.02 version soon for fixing that.
Fixed error in Input.press?.
hey, I can't use my gamepad.. with your AIM, i'm quite surprised lol of that issue.

None of my keys are working but it works perfectly with a default project.

I've might find why: (i need to check) get_keyboard_state in the update only return state of the keyboard and doesn't include the state of the gamepad.
I haven't implemented gamepad detection yet, but I will try to do it. I am a bit busy by this times, school, some projects and more, but I will start searching the msnd for gamepad APIs.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=10631