AWorks Input Module

AW Input Module
Created by AWorks (vgvgf)
Version: 3.00
Last Updated: 26/01/2009(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.

New in version 3.00 BETA
In this new version I use a DLL for the input updating, which is faster than ever.

New in version 3.00 Release
Now it includes a mouse pluging for mouse input detection. It includes cursor pos, doubleclick and drag detecting.

Next Developement
I plan to add mouse wheel functionality, wrting system, and more. Also, suggest your ideas.

Download
ADemo VX.rar
ADemo VX.zip
ADemo XP.rar
ADemo XP.zip
AWorks Script Pack.rar
AWorks Script Pack.zip

Special Thanks
* Poccil(Peter O.)
  - For his researchs on modifing ruby objects with C
* ERZENGEL
  - For his help in editing ruby strings with C


Please, give me credit if you use my script.

PD: The downloads includes also a bitmap rotating method, that doesn't fit with this post, but it is included.
Quote:
Last Updated: 30/11/2007

orly?
RezydentX wrote:
Quote:
Last Updated: 30/11/2007

orly?
Thanks, now is correct.
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?
eval("Keys::#{Keys.constants[Keys.constants.index(name)]}")
Expand to see the code.

THIS is WORSE!!
use
Keys.const_get(name)
Expand to see the code.


PS: can your input detect "äöü" and other funny keys ala "Ŋ" ?

PPS: the last i do with Alt-Gr + Shift + G
...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=Standard Convention]
@> Conditonal Branch: The DOWN button is being pressed
  @> Play SE: '004-System04', '100', '100'
  @>
@>[/code]

...Doesn't do anything, you have to do...

[code=Call Script Convention]@> Conditonal Branch: Script: Input.press?(Input::DOWN)
  @> Play SE: '004-System04', '100', '100'
  @>
@>[/code]

...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.

Input Interpreter Patch Spoiler
#=============================================================================
# *** 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
Expand to see the code.


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.

SDK Part 2 : Individual ("INTERPRETER#COMMAND_111") Spoiler
#==============================================================================
# ** 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
Expand to see the code.

Input Interpreter Patch (SDK Ver 2.5) Spoiler
#=============================================================================
# *** 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
Expand to see the code.


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.
äöü can i input because i have a german keyboard layout

Ã…Å  can i input bacause i have linux :P
Quote:
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.

Quote:
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.

Quote:
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.
I have not included that yet, because I am also rewritting them and the script is now in BETA version.

Quote:
Can your Input or Keys module detect the Mouse wheel scrolling up/down?
Not yet, but I will see if I can include that for the release version.

@hanmac, thanks I will update that. Also, äëïöü, áéíóú, àèìòù, and more characters, can be detected as buttons, but not seeing which characters it represents. However with my other script, a writing system, these characters all well detected. Also, I am rewritting the writing system, too.

Quote:
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.
My idea is to alias the "p" and "print" methods, and say to the input module not to update next frame. I will see if it work.
can your mouse input also check the position of the mouse?
Quote:
can your mouse input also check the position of the mouse?


The other scripts I found are slow. So, Vgvgf, if your DLL can do this too, it will be cool. :)


Quote:
Can your Input or Keys module detect the Mouse wheel scrolling up/down?


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 ?
Hi, king
3 apis pour la reception de données externes / you've to use these Win32apis to send the scrollwheel message to the window
get_message = Win32API.new('User32', 'GetMessage', 'plll', 'l')
translate_message = Win32API.new('User32', 'TranslateMessage', 'p', 'l')
dispatch_message = Win32API.new('User32', 'DispatchMessage', 'p', 'l')
Expand to see the code.


et j'ai un lien pour toi: ^^ / I give you an url about it:
ici/here
le probleme c'est que le systeme est très lent / but this system is quite slow...
pas réussi à l'optimiser... pour scroller la map...

amicalement/best regards

berka
> berka
I'm in interest with this script. I want to use some kind of :

if Input::trigger?(Input::WheelDown)
Expand to see the code.


For my applications.

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. ;)

I send a MP to vgvgf to have explanations about compatibility with your script (I didn't notice your answer).
Quote:
can your mouse input also check the position of the mouse?
I haven't added mouse functions yet, but I will.
Quote:
Can your Input or Keys module detect the Mouse wheel scrolling up/down?
I am working on that.
Quote:
et j'ai un lien pour toi: ^^ / I give you an url about it:
ici/here
le probleme c'est que le systeme est très lent / but this system is quite slow...
pas réussi à l'optimiser... pour scroller la map...
Thanks, I will see how can I convert this to C for DLL, or something better if I can find something so.
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. ;)
Expand to see the code.
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.
GREAT!!!

now i only need a window where you can input letters (and use your dll)

PS: i shound be use the keyboard layout

Edit:

error:

Quote:
#-------------------------------------------------------------------------
# * Get RTP Path
#-------------------------------------------------------------------------
def get_rtp_path(rtp = 0)
API::RGSSGetPathWithRTP.call(API::RGSSGetRTPPath.cal(rtp))
end


PS: can i turn your script into a APD version? (you also get credit)
*bump*


Question: does your script support qwertz-keyboards?

or can you get the string of the key witch is set by the keybroad layout?
Quote:
can i turn your script into a APD version? (you also get credit)

Quote:
Question: does your script support qwertz-keyboards?
or can you get the string of the key witch is set by the keybroad layout?
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?
this is for mouse wheel:

  1. =begin
  2.  
  3. RGSS MOUSE WHEEL (VERSION 2)
  4.  
  5. == Credits ==
  6. Copyright 2009 by Cremno (cremno[A mit Kringel]mail[PÜNKTCHEN]ru).
  7.  
  8. == License ==
  9. Published under http://creativecommons.org/licenses/by-sa/3.0/
  10.  
  11. =end
  12.  
  13. module WinAPI
  14.  
  15.   module Functions
  16.  
  17.     def self.add(proc, import, export = 'L', dllname = @dll_name)
  18.       ::Win32API.new(dllname, proc, import, export)
  19.     end
  20.  
  21.     @dll_name = 'user32'
  22.     GetMessage       = add('GetMessage',       'PLLL')
  23.     TranslateMessage = add('TranslateMessage', 'P'   )
  24.     DispatchMessage  = add('DispatchMessage',  'P'   )
  25.   end
  26.  
  27.   module Structures
  28.     MSG = "\0" * 32
  29.   end
  30.  
  31.   module Macros
  32.     UnpackDWORD = lambda do |buffer, offset|
  33.       retval  =  buffer[offset]                 & 0x000000FF
  34.       retval |= (buffer[offset + 1] << (8 * 1)) & 0x0000FF00
  35.       retval |= (buffer[offset + 2] << (8 * 2)) & 0x00FF0000
  36.       retval |= (buffer[offset + 3] << (8 * 3)) & 0xFF000000
  37.       retval
  38.     end
  39.  
  40.     LOWORD = lambda do |n|
  41.       n & 0xFFFF
  42.     end
  43.  
  44.     HIWORD = lambda do |l|
  45.       (l >> 16) & 0xFFFF
  46.     end
  47.  
  48.     GET_WHEEL_DELTA_WPARAM = lambda do |wparam|
  49.        hiword = HIWORD.call(wparam)
  50.        (hiword & 0x8000).zero? ? hiword : -1 * ((~hiword & 0x7FFF).succ)
  51.     end
  52.   end
  53.  
  54.   [Functions, Structures, Macros].each do |mod|
  55.     mod.constants.each{|const| const.freeze}
  56.   end
  57.  
  58. end
  59.  
  60.  
  61. Mouse = Module.new if !Object.const_defined?(:Mouse)
  62.  
  63. module Mouse::Wheel
  64.  
  65.   WHEEL_DELTA = 120.freeze
  66.  
  67.   def self.delta()
  68.     msg = ::WinAPI::Structures::MSG.dup
  69.     retval = ::WinAPI::Functions::GetMessage.call(msg, 0, 0, 0)
  70.     case retval
  71.       when -1  # Error
  72.         section_name = $RGSS_SCRIPTS.at(__FILE__.sub(/Section/, '').to_i).at(1)
  73.         raise("Skript '#{section_name}': Fehler bei Anruf von GetMessage!")
  74.       when  0  # WM_QUIT
  75.         exit()
  76.       else
  77.         ::WinAPI::Functions::TranslateMessage.call(msg)
  78.         ::WinAPI::Functions::DispatchMessage.call(msg)
  79.         if ::WinAPI::Macros::UnpackDWORD.call(msg, 4).eql?(522)  # MSG->message
  80.           wparam = ::WinAPI::Macros::UnpackDWORD.call(msg, 8)    # MSG->wParam
  81.           return ::WinAPI::Macros::GET_WHEEL_DELTA_WPARAM.call(wparam)
  82.         end
  83.     end
  84.     0
  85.   end
  86.  
  87.   def self.rotation_direction()
  88.     d = delta()
  89.     d.zero? ? (:none) : ((d > 0) ? (:up) : (:down))
  90.   end
  91.  
  92. end
Expand to see the code.
Thanks hanmac. I will see if I make some free time for updating the script, now that you remembered me that I still have to finish some things.
im still there and waiting for your great things xD
I'm (im)patiently waiting for you to update this, the Mouse wheel function is what I need most.
Well, I have a really big problem for adding the mouse wheel function. My mouse hasn't wheel... I will see if I buy a new mouse, for testing what I make. So you will have to wait a bit longer.
if you have bought one theres a new script with a dll for this

new dll:
http://www.rpg-studio.de/forum/rpg-stud ... use-wheel/

dll txt:
http://www.mediafire.com/?m2mmwwgntxt
hello vgvgf,

It's been a long time since I was here. You've updated this script nicely. I have, however, found a slight glitch/bug:

If you press one of the keys affected by Num Lock then press Num Lock at the same time, the key is stuck as being pressed until you switch Num Lock and press and release the key again.

Thanks and I hope to be around more often:

Draycos Goldaryn

PS: Do I still give credit to Aleworks, or is credit now due to AWorks?
Long time I didn't see you DraycosGoldaryn, nice you are back. Thanks for reporting that bug, I will test so and see how to fix it. Hehe, also credit now AWorks or just vgvgf, I have changed it cause Aleworks can be confused with beer and else.

Also, I have bought a new mouse with wheel! This script was an excelent excuse for buying it, hehe. I will see to add mouse wheel detection now.
Cool, as soon as you get that updated then I can remove the MACL's Mouse/Keyboard scripts, and anything related that isn't AWorks from my project! Besides, some of the non-AWorks scripts give me real headbutt problems, so you're like a godsend to us scripters that want to use mouse/keyboard stuff :P

Since you know this Win32API / C coding stuff better than I do, I'm gonna ask you if you can help me with something;

I wrote a script for a Sprite_MouseCursor (which hides the system cursor and uses a sprite instead). My sprite script works fine, but when I press F1 to open the Option tab (or if a print window pops up) my Mouse cursor is still hidden so long as it is above the Game.exe window or any of it's sub-windows, meaning I can't see where the real mouse is while editing options. Is there any way you'd be able to remedy that for me or tell me how to fix that?

Looking forward to the official AWork's Mouse-wheel function, this is something I need the most!
Solving the problem for pop ups windows is easy, just do:
  1. alias mp p
  2. def p(*args)
  3.   aAWorks::API::ShowCursor.call(1)
  4.   mp(*args)
  5.   AWorks::API::ShowCursor.call(0)
  6. end
  7. alias mprint print
  8. def print(*args)
  9.   AWorks::API::ShowCursor.call(1)
  10.   mprint(*args)
  11.   AWorks::API::ShowCursor.call(0)
  12. end
Expand to see the code.


But it is really more complicated for the F1 menu. Maybe making a hook for the F1 key, so it will be able to show the cursor before the F1 Accelerator is called, and then hiding the cursor again after the F1 window is closed. The problem is that I don't know about hooks... I still have to learn that.

Or a less professional way to solve this can be editing the F1 Accelerator from a decompressed RGSS dll with ResHacker. That way you can assing to the configuration menu other key insteand of F1, for example Virtual Key 255, which is not used by any keyboard. And then adding a method for checking F1 key and calling that VK:
  1. module Input
  2.   unless self.method_defined?(:cursor_update)
  3.      alias_method(:cursor_update, :update)
  4.   end
  5.   def self.update
  6.      cursor_update
  7.      if @trigger[Keys::F1]
  8.         AWorks::API::ShowCursor.call(1)
  9.         AWorks::API::Keybd_Event.call(255, 0, 0, 0)
  10.         AWorks::API::Keybd_Event.call(255, 0, 2, 0)
  11.         AWorks::API::ShowCursor.call(0)
  12.      end
  13.   end
  14. end
Expand to see the code.
I tried what you did with the p/print thing before, it only works the first time I do it, after that it doesn't work very well. The problem lies within the fact that Ruby vs C is too slow. I definately noticed this when I made my Sprite_MouseCursor class, which automatically hides the real cursor; I notice the system cursor takes about 2 or 3 seconds to hide itself when the sprite pops up, when it should be instant the sprite cursor is initialized but oh well.

I don't mind the p/print one so much as the F1 issue, especially since all you need to kill the print window is to press Enter, but its okay I'll probably just find a way to disable F1 altogether and just code a Control scheme into my CMS's config scene (besides, I needed more Config options anyway).

Thank you for your help, I appreciate it! :thumb:

If you can, PM me once the Mouse wheel is integrated into AWorks. I'm using the dll/script hanmac posted and, don't get me wrong it actually works great, but I'm weird and I like things to all be in one package lol.
I must say, this script is amazing..!! This is just what I have been looking for.

One problem, it is now rendering a script I need working, to not work: "Glitchfinder's Multiple Timers (Version 2.32)"

Is there anyway to make it work with this script that I am not seeing?

Content Hidden Spoiler
  1. #==============================================================================
  2. # ** Glitchfinder's Multiple Timers (Version 2.32)
  3. #------------------------------------------------------------------------------
  4. #   This script helps scripters and eventers use multiple hidden in-game timers
  5. # that can be called and modified at any time.
  6. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7. # * Version History
  8. #   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  9. #    Version 1 ---------------------------------------------------- (??????????)
  10. #    Version 2 ---------------------------------------------------- (2008-06-11)
  11. #      - Script completely rewritten to work with multiple timers.
  12. #      Version 2.1 ------------------------------------------------- (2002-06-18)
  13. #       - Added the check_timing() command. Bug with check() command fixed.
  14. #      Version 2.11 ------------------------------------------------ (2007-06-19)
  15. #       - Reformatted and cleaned script.
  16. #      Version 2.21 ------------------------------------------------ (2007-06-22)
  17. #       - Added the extended_start() command.
  18. #      Version 2.31 ------------------------------------------------ (2007-07-20)
  19. #       - Added the update_single(), kill_timer(), and adjust_time() commands.
  20. #      Version 2.32 ------------------------------------------------ (2007-07-24)
  21. #       - Fixed bug with VX and the start() aand extended_start() commands.
  22. #
  23. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  24. # * Instructions
  25. # - -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  26. #
  27. #   Place this script above Main, and below the default scripts. (I realize this
  28. # is obvious to most, but some people don't get it.)
  29. #
  30. #
  31. #
  32. #   To start a timer, use the following call:
  33. #
  34. #    $game_temp.game_timer.start(seconds, timer_number)
  35. #
  36. # Where seconds is the number of seconds you want the timer to run, and
  37. # timer_number is the number of that specific timer. You must use a seperate
  38. # number for every timer, because when one finishes, only the first script
  39. # checking for that number will return with the timer completed.
  40. #
  41. #
  42. #
  43. #   To start an extended timer, use the following call:
  44. #
  45. #    $game_temp.game_timer.extended_start(hours, minutes, seconds, timer_number)
  46. #
  47. # Where hours, minutes, and seconds are the number of hours, minutes, and
  48. # seconds you wish the timer to run. timer_number follows the same rules as it
  49. # does in the method above.
  50. #
  51. #
  52. #
  53. #   To check whether or not a timer has finished, use the following call:
  54. #
  55. #    $game_temp.game_timer.check(timer_number)
  56. #
  57. # Where timer_number is the number of the timer that you need to check. See the
  58. # rules above regarding timer_number.
  59. #
  60. #
  61. #
  62. #   To stop a timer, you use the following call:
  63. #
  64. #    $game_temp.game_timer.kill_timer(timer_number)
  65. #
  66. # Where timer_number is the number of the timer you wish to stop. Please read
  67. # the above rules regarding timer_number.
  68. #
  69. #
  70. #
  71. #   To adjust the remaining time, use the following call:
  72. #
  73. #    $game_temp.game_timer.adjust_time(setting, value, timer_number)
  74. #
  75. # Where setting is what kind of operation you wish to perform. (1 for addition,
  76. # 2 for subtraction, 3 for multiplication, and 4 for division) Value must be
  77. # the number of seconds you wish to add or subtract, or the number you wish to
  78. # add or divide by. Finally, timer_number is the number of the timer you wish
  79. # to edit. (Once again, see above for rules regarding timer_number)
  80. #
  81. #
  82. #
  83. #   To update a single timer seperately, you must use the following call:
  84. #
  85. #    $game_temp.game_timer.update_single(timer_number)
  86. #
  87. # Where timer_number is the number of the timer you wish to update. This is
  88. # meant to be used to update specific timers in scenes that this script doesn't
  89. # normall update in. (In other words, anything other than Scene_Map) It can
  90. # also be used to update a specific timer at a rate that is faster than normal,
  91. # when variable speeds are necessary.
  92. #
  93. #
  94. #
  95. #   For debugging purposes, check the timer with the following call:
  96. #
  97. #    $game_temp.game_timer.check_timing(timer_number)
  98. #
  99. # Where timer_number is the number of the timer you are checking. (once again,
  100. # see above for details on timer_number) It will either display the remaining
  101. # frames before the timer is finished, or it will tell you that the timer has
  102. # finished.
  103. #
  104. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  105. #
  106. # * Advice
  107. #   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  108. #   This script is meant for people with at least basic scripting knowledge. It
  109. # may be difficult to use, and thus, if you are unsure of you're abilities, it
  110. # may be simpler to avoid scripted timing.
  111. #
  112. #   This script has been tested in both script and events, and will function in
  113. # both cases.
  114. #
  115. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  116. #
  117. # * Usage
  118. #   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  119. #   This script may be used in any commercial or non-commercial project.
  120. #
  121. #   Please credit Glitchfinder if you use this script.
  122. #==============================================================================
  123.  
  124. #==============================================================================
  125. # ** Game_Temp
  126. #------------------------------------------------------------------------------
  127. #   This class handles temporary data that is not included with save data.
  128. #   Refer to "$game_temp" for the instance of this class.
  129. #==============================================================================
  130.  
  131. class Game_Temp
  132.   attr_accessor :game_timer
  133.  
  134.   alias old_init initialize
  135.   def initialize
  136.      old_init
  137.      @game_timer = Game_Timer.new
  138.   end
  139. end
  140.  
  141. #==============================================================================
  142. # ** Scene_Map
  143. #------------------------------------------------------------------------------
  144. #   This class performs map screen processing.
  145. #==============================================================================
  146.  
  147. class Scene_Map
  148.   alias old_update update
  149.   def update
  150.      #old_update
  151.      $game_temp.game_timer.update
  152.      old_update
  153.   end
  154. end
  155.  
  156. #==============================================================================
  157. # ** Game_Timer
  158. #------------------------------------------------------------------------------
  159. #   This class performs processing for in-script timers.
  160. # Refer to "$game_temp.game_timer" for the instance of this class.
  161. #==============================================================================
  162.  
  163. class Game_Timer
  164.   module Timers
  165.      # This is the actual timer, each value is a number of frames
  166.      Timers = [
  167.         0
  168.      ]
  169.      # This tells the script that a timer is currently active
  170.      Active_Timers = [
  171.         2
  172.      ]
  173.      # This stores the specific number for each active timer
  174.      Timer_Numbers = [
  175.         0
  176.      ]
  177.      # This tells the script which timers have finished
  178.      Finished_Timer_Numbers = [
  179.         0
  180.      ]
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Update Timer
  184.   #--------------------------------------------------------------------------
  185.   def update
  186.      # While there is an active timer,
  187.      while Timers::Active_Timers.include?(1)
  188.         # Return the number of the active timer
  189.         position = Timers::Active_Timers.index(1)
  190.         # Temporarily set the timer info to 0
  191.         Timers::Active_Timers[position] = 0
  192.         # Set value to current frame count and subtract one
  193.         array_value = Timers::Timers[position]
  194.         value = array_value.to_s.to_i
  195.         value -= 1
  196.         # Update frame count in the array
  197.         Timers::Timers[position] = value.to_a
  198.         # If the frame count is <= 0,
  199.         if value <= 0
  200.            # Add the timer number to the correct array, to indicate it is finished
  201.            dead_timer = Timers::Timer_Numbers[position]
  202.            timer_number = dead_timer.to_s.to_i
  203.            Timers::Finished_Timer_Numbers.insert 1, timer_number
  204.            # Delete the current timer's frame count and information
  205.            Timers::Timers.delete_at(position)
  206.            Timers::Active_Timers.delete_at(position)
  207.            Timers::Timer_Numbers.delete_at(position)
  208.         end
  209.      end
  210.      # While there are active timers with info set temporarily to 0,
  211.      while Timers::Active_Timers.include?(0)
  212.         # Set their info back to 1
  213.         position = Timers::Active_Timers.index(0)
  214.         Timers::Active_Timers[position] = 1
  215.      end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Update Specific Timer
  219.   #--------------------------------------------------------------------------
  220.   def update_single(timer_number)
  221.      # Find the position of the specified timer
  222.      position = Timers::Timer_Numbers.index(timer_number)
  223.      # If the specified timer is running,
  224.      if position != nil
  225.         # Set value to current frame count and subtract one
  226.         array_value = Timers::Timers[position]
  227.         value = array_value.to_s.to_i
  228.         value -= 1
  229.         # Update frame count in the array
  230.         Timers::Timers[position] = value.to_a
  231.         # If the frame count is <= 0,
  232.         if value <= 0
  233.            # Add the timer number to the correct array, to indicate it is finished
  234.            Timers::Finished_Timer_Numbers.insert 1, timer_number
  235.            # Delete the current timer's frame count and information
  236.            Timers::Timers.delete_at(position)
  237.            Timers::Active_Timers.delete_at(position)
  238.            Timers::Timer_Numbers.delete_at(position)
  239.         end
  240.      end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Start Timer
  244.   #--------------------------------------------------------------------------
  245.   def start(seconds, timer_number)
  246.      # Add frame count to the correct array
  247.      Timers::Timers.insert(1,[seconds*Graphics.frame_rate])
  248.      # Set the timer to active
  249.      Timers::Active_Timers.insert(1, 1)
  250.      # Set the timer number
  251.      Timers::Timer_Numbers.insert(1, timer_number)
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # * Extended Start Timer
  255.   #--------------------------------------------------------------------------
  256.   def extended_start(hours, minutes, seconds, timer_number)
  257.      # Add frame count to the correct array
  258.      Timers::Timers.insert(1,[(hours*3600*(Graphics.frame_rate)) +
  259.      (minutes*(60*Graphics.frame_rate)) + (seconds*Graphics.frame_rate)])
  260.      # Set the timer to active
  261.      Timers::Active_Timers.insert(1, 1)
  262.      # Set the timer number
  263.      Timers::Timer_Numbers.insert(1, timer_number )
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # * Check Timer
  267.   #--------------------------------------------------------------------------
  268.   def check(timer_number)
  269.      # If the timer number matches a finished timer,
  270.      if Timers::Finished_Timer_Numbers.include?(timer_number)
  271.         # Delete the data from the array
  272.         Timers::Finished_Timer_Numbers.delete(timer_number)
  273.         # Return as finished
  274.         return true
  275.      else
  276.         # Return as still timing
  277.         return false
  278.      end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # * Check Timer (Debugging)
  282.   #--------------------------------------------------------------------------
  283.   def check_timing(timer_number)
  284.      if Timers::Timer_Numbers.include?(timer_number)
  285.         # Set position to specified timer
  286.         position = Timers::Timer_Numbers.index(timer_number)
  287.         # If the timer is still running,
  288.         # If the specified timer is finished,
  289.         if Timers::Timers[position] == nil
  290.            # Print "Time is up."
  291.            print "Time is up."
  292.         # Otherwise,
  293.         else
  294.            # Print number of remaining frames
  295.            time = Timers::Timers[position].to_s
  296.            print time
  297.         end
  298.      else
  299.         # Print "Time is up."
  300.         print "Time is up."
  301.      end
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * Kill Timer
  305.   #--------------------------------------------------------------------------
  306.   def kill_timer(timer_number)
  307.      # Set position to the current timer
  308.      position = Timers::Timer_Numbers.index(timer_number)
  309.      # If the specified timer is still running,
  310.      if position != nil
  311.         # Add the timer number to the correct array, to indicate it is finished
  312.         Timers::Finished_Timer_Numbers.insert 1, timer_number
  313.         # Delete the current timer's frame count and information
  314.         Timers::Timers.delete_at(position)
  315.         Timers::Active_Timers.delete_at(position)
  316.         Timers::Timer_Numbers.delete_at(position)
  317.      end
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Adjust Remaining Time
  321.   #--------------------------------------------------------------------------
  322.   def adjust_time(setting, value, timer_number)
  323.      position = Timers::Timer_Numbers.index(timer_number)
  324.      case setting
  325.      when 1
  326.         time = Timers::Timers[position].to_i
  327.         new_time = time + (value * Graphics.frame_rate)
  328.         Timers::Timers[position] = new_time.to_a
  329.      when 2
  330.         time = Timers::Timers[position].to_i
  331.         new_time = time - (value * Graphics.frame_rate)
  332.         Timers::Timers[position] = new_time.to_a
  333.      when 3
  334.         time = Timers::Timers[position].to_i
  335.         new_time = time * value
  336.         Timers::Timers[position] = new_time.to_a
  337.      when 4
  338.         time = Timers::Timers[position].to_i
  339.         new_time = time / value
  340.         Timers::Timers[position] = new_time.to_a
  341.      end
  342.   end      
  343. end
Expand to see the code.


Problem: The timers stop working and do not count down. When checking the timers, they report that they have alread finished counting down. I also recieve an error message stating:

"Script' =Library(ALibrary)' line 677: TypeError occurred. cannot convert Fixnum into Array"


Any help on this is apprieciated.

Fenwick

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