Envision, Create, Share

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

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.
 
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:
Code:
alias mp p

def p(*args)

  aAWorks::API::ShowCursor.call(1)

  mp(*args)

  AWorks::API::ShowCursor.call(0)

end

alias mprint print

def print(*args)

  AWorks::API::ShowCursor.call(1)

  mprint(*args)

  AWorks::API::ShowCursor.call(0)

end

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:
Code:
module Input

  unless self.method_defined?(:cursor_update)

    alias_method(:cursor_update, :update)

  end

  def self.update

    cursor_update

    if @trigger[Keys::F1]

      AWorks::API::ShowCursor.call(1)

      AWorks::API::Keybd_Event.call(255, 0, 0, 0)

      AWorks::API::Keybd_Event.call(255, 0, 2, 0)

      AWorks::API::ShowCursor.call(0)

    end

  end

end
 
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?

Code:
#==============================================================================

# ** Glitchfinder's Multiple Timers (Version 2.32)

#------------------------------------------------------------------------------

#  This script helps scripters and eventers use multiple hidden in-game timers

# that can be called and modified at any time.

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# * Version History

#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

#   Version 1 ---------------------------------------------------- (??????????)

#   Version 2 ---------------------------------------------------- (2008-06-11)

#    - Script completely rewritten to work with multiple timers.

#    Version 2.1 ------------------------------------------------- (2002-06-18)

#     - Added the check_timing() command. Bug with check() command fixed.

#    Version 2.11 ------------------------------------------------ (2007-06-19)

#     - Reformatted and cleaned script.

#    Version 2.21 ------------------------------------------------ (2007-06-22)

#     - Added the extended_start() command.

#    Version 2.31 ------------------------------------------------ (2007-07-20)

#     - Added the update_single(), kill_timer(), and adjust_time() commands.

#    Version 2.32 ------------------------------------------------ (2007-07-24)

#     - Fixed bug with VX and the start() aand extended_start() commands.

#

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# * Instructions

# - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

#

#  Place this script above Main, and below the default scripts. (I realize this

# is obvious to most, but some people don't get it.)

#

#

#

#  To start a timer, use the following call:

#

#   $game_temp.game_timer.start(seconds, timer_number)

#

# Where seconds is the number of seconds you want the timer to run, and

# timer_number is the number of that specific timer. You must use a seperate

# number for every timer, because when one finishes, only the first script

# checking for that number will return with the timer completed.

#

#

#

#  To start an extended timer, use the following call:

#

#   $game_temp.game_timer.extended_start(hours, minutes, seconds, timer_number)

#

# Where hours, minutes, and seconds are the number of hours, minutes, and

# seconds you wish the timer to run. timer_number follows the same rules as it

# does in the method above.

#

#

#

#  To check whether or not a timer has finished, use the following call:

#

#   $game_temp.game_timer.check(timer_number)

#

# Where timer_number is the number of the timer that you need to check. See the

# rules above regarding timer_number.

#

#

#

#  To stop a timer, you use the following call:

#

#   $game_temp.game_timer.kill_timer(timer_number)

#

# Where timer_number is the number of the timer you wish to stop. Please read

# the above rules regarding timer_number.

#

#

#

#  To adjust the remaining time, use the following call:

#

#   $game_temp.game_timer.adjust_time(setting, value, timer_number)

#

# Where setting is what kind of operation you wish to perform. (1 for addition,

# 2 for subtraction, 3 for multiplication, and 4 for division) Value must be

# the number of seconds you wish to add or subtract, or the number you wish to

# add or divide by. Finally, timer_number is the number of the timer you wish

# to edit. (Once again, see above for rules regarding timer_number)

#

#

#

#  To update a single timer seperately, you must use the following call:

#

#   $game_temp.game_timer.update_single(timer_number)

#

# Where timer_number is the number of the timer you wish to update. This is

# meant to be used to update specific timers in scenes that this script doesn't

# normall update in. (In other words, anything other than Scene_Map) It can

# also be used to update a specific timer at a rate that is faster than normal,

# when variable speeds are necessary.

#

#

#

#  For debugging purposes, check the timer with the following call:

#

#   $game_temp.game_timer.check_timing(timer_number)

#

# Where timer_number is the number of the timer you are checking. (once again,

# see above for details on timer_number) It will either display the remaining

# frames before the timer is finished, or it will tell you that the timer has

# finished.

#

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#

# * Advice

#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

#  This script is meant for people with at least basic scripting knowledge. It

# may be difficult to use, and thus, if you are unsure of you're abilities, it

# may be simpler to avoid scripted timing.

#

#  This script has been tested in both script and events, and will function in

# both cases.

#

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#

# * Usage

#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

#  This script may be used in any commercial or non-commercial project.

#

#  Please credit Glitchfinder if you use this script.

#==============================================================================

 

#==============================================================================

# ** Game_Temp

#------------------------------------------------------------------------------

#  This class handles temporary data that is not included with save data.

#  Refer to "$game_temp" for the instance of this class.

#==============================================================================

 

class Game_Temp

  attr_accessor :game_timer

 

  alias old_init initialize

  def initialize

    old_init

    @game_timer = Game_Timer.new

  end

end

 

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  This class performs map screen processing.

#==============================================================================

 

class Scene_Map

  alias old_update update

  def update

    #old_update

    $game_temp.game_timer.update

    old_update

  end

end

 

#==============================================================================

# ** Game_Timer

#------------------------------------------------------------------------------

#  This class performs processing for in-script timers.

# Refer to "$game_temp.game_timer" for the instance of this class.

#==============================================================================

 

class Game_Timer

  module Timers

    # This is the actual timer, each value is a number of frames

    Timers = [

      0

    ]

    # This tells the script that a timer is currently active

    Active_Timers = [

      2

    ]

    # This stores the specific number for each active timer

    Timer_Numbers = [

      0

    ]

    # This tells the script which timers have finished

    Finished_Timer_Numbers = [

      0

    ]

  end

  #--------------------------------------------------------------------------

  # * Update Timer

  #--------------------------------------------------------------------------

  def update

    # While there is an active timer,

    while Timers::Active_Timers.include?(1)

      # Return the number of the active timer

      position = Timers::Active_Timers.index(1)

      # Temporarily set the timer info to 0

      Timers::Active_Timers[position] = 0

      # Set value to current frame count and subtract one

      array_value = Timers::Timers[position]

      value = array_value.to_s.to_i

      value -= 1

      # Update frame count in the array

      Timers::Timers[position] = value.to_a

      # If the frame count is <= 0,

      if value <= 0

        # Add the timer number to the correct array, to indicate it is finished

        dead_timer = Timers::Timer_Numbers[position]

        timer_number = dead_timer.to_s.to_i

        Timers::Finished_Timer_Numbers.insert 1, timer_number

        # Delete the current timer's frame count and information

        Timers::Timers.delete_at(position)

        Timers::Active_Timers.delete_at(position)

        Timers::Timer_Numbers.delete_at(position)

      end

    end

    # While there are active timers with info set temporarily to 0,

    while Timers::Active_Timers.include?(0)

      # Set their info back to 1

      position = Timers::Active_Timers.index(0)

      Timers::Active_Timers[position] = 1

    end

  end

  #--------------------------------------------------------------------------

  # * Update Specific Timer

  #--------------------------------------------------------------------------

  def update_single(timer_number)

    # Find the position of the specified timer

    position = Timers::Timer_Numbers.index(timer_number)

    # If the specified timer is running,

    if position != nil

      # Set value to current frame count and subtract one

      array_value = Timers::Timers[position]

      value = array_value.to_s.to_i

      value -= 1

      # Update frame count in the array

      Timers::Timers[position] = value.to_a

      # If the frame count is <= 0,

      if value <= 0

        # Add the timer number to the correct array, to indicate it is finished

        Timers::Finished_Timer_Numbers.insert 1, timer_number

        # Delete the current timer's frame count and information

        Timers::Timers.delete_at(position)

        Timers::Active_Timers.delete_at(position)

        Timers::Timer_Numbers.delete_at(position)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Start Timer

  #--------------------------------------------------------------------------

  def start(seconds, timer_number)

    # Add frame count to the correct array

    Timers::Timers.insert(1,[seconds*Graphics.frame_rate])

    # Set the timer to active

    Timers::Active_Timers.insert(1, 1)

    # Set the timer number

    Timers::Timer_Numbers.insert(1, timer_number)

  end

  #--------------------------------------------------------------------------

  # * Extended Start Timer

  #--------------------------------------------------------------------------

  def extended_start(hours, minutes, seconds, timer_number)

    # Add frame count to the correct array

    Timers::Timers.insert(1,[(hours*3600*(Graphics.frame_rate)) +

    (minutes*(60*Graphics.frame_rate)) + (seconds*Graphics.frame_rate)])

    # Set the timer to active

    Timers::Active_Timers.insert(1, 1)

    # Set the timer number

    Timers::Timer_Numbers.insert(1, timer_number )

  end

  #--------------------------------------------------------------------------

  # * Check Timer

  #--------------------------------------------------------------------------

  def check(timer_number)

    # If the timer number matches a finished timer,

    if Timers::Finished_Timer_Numbers.include?(timer_number)

      # Delete the data from the array

      Timers::Finished_Timer_Numbers.delete(timer_number)

      # Return as finished

      return true

    else

      # Return as still timing

      return false

    end

  end

  #--------------------------------------------------------------------------

  # * Check Timer (Debugging)

  #--------------------------------------------------------------------------

  def check_timing(timer_number)

    if Timers::Timer_Numbers.include?(timer_number)

      # Set position to specified timer

      position = Timers::Timer_Numbers.index(timer_number)

      # If the timer is still running,

      # If the specified timer is finished,

      if Timers::Timers[position] == nil

        # Print "Time is up."

        print "Time is up."

      # Otherwise,

      else

        # Print number of remaining frames

        time = Timers::Timers[position].to_s

        print time

      end

    else

      # Print "Time is up."

      print "Time is up."

    end

  end

  #--------------------------------------------------------------------------

  # * Kill Timer

  #--------------------------------------------------------------------------

  def kill_timer(timer_number)

    # Set position to the current timer

    position = Timers::Timer_Numbers.index(timer_number)

    # If the specified timer is still running,

    if position != nil

      # Add the timer number to the correct array, to indicate it is finished

      Timers::Finished_Timer_Numbers.insert 1, timer_number

      # Delete the current timer's frame count and information

      Timers::Timers.delete_at(position)

      Timers::Active_Timers.delete_at(position)

      Timers::Timer_Numbers.delete_at(position)

    end

  end

  #--------------------------------------------------------------------------

  # * Adjust Remaining Time

  #--------------------------------------------------------------------------

  def adjust_time(setting, value, timer_number)

    position = Timers::Timer_Numbers.index(timer_number)

    case setting

    when 1

      time = Timers::Timers[position].to_i

      new_time = time + (value * Graphics.frame_rate)

      Timers::Timers[position] = new_time.to_a

    when 2

      time = Timers::Timers[position].to_i

      new_time = time - (value * Graphics.frame_rate)

      Timers::Timers[position] = new_time.to_a

    when 3

      time = Timers::Timers[position].to_i

      new_time = time * value

      Timers::Timers[position] = new_time.to_a

    when 4

      time = Timers::Timers[position].to_i

      new_time = time / value

      Timers::Timers[position] = new_time.to_a

    end

  end     

end

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
 
You might want to explain a little bit more about the conflicts you encounter when you use these two scripts together, especially since they don't have any common relation to each other. Is there some kind of syntax/method error you encounter when you use them both? Does your game start acting funny? Does your timers stop working? What exactly happens?
 
hey vgvgf!
I really enjoy your script, but i got one problem:

when i whirl around the mouse in the screen the fps drops down to 19...
And in a shooting game, where run the 8-ways, you need to whirl the mouse around, to aim fast at plenty of enemies.

greetings to everybody, but mario, i hate him...^^
 
Hello again, I've been playing around a bit more with this script, and noticed a difference in array input.

A single array still works as the return value is true when at least one of virtual keys in the array are true for the corresponding method, but sub-arrays don't work. in your old script the Sub-Arrays will have true value only when all of its values are true for the corresponding method. Now however, it returns an error:

"Cannot convert Array into Integer"

Are you planning to include support for sub-arrays again?
Are you also planning to reintroduce key combos?

Thank you,

Draycos Goldaryn
 
DraycosGoldaryn":33u6kjj2 said:
Now however, it returns an error:

"Cannot convert Array into Integer"

As I said in my post, 4 posts back, I am also getting this error:

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

When using the this script with the script I posted in my last post. And as Kain Nobel pointed out, they are two unrelated scripts.
 
@Fenwick, delete this method in the ALibrary class. I will delete it in future version, but provisionaly, just all people delete it, as it may cause conflictts with some other scripts too.
Code:
  #---------------------------------------------------------------------------

  # * Insert

  #---------------------------------------------------------------------------

  def insert(i, obj)

    if i == 0

      obj + self

    elsif i == self.size

      self + obj

    elsif self.size < i

      self + Array.new(i - self.size) +  obj

    else

      self[0, i - 1] + obj + self[i, self.size]

    end

  end
It seems that RMXP Ruby already has the .insert and I am overwritting with a custom function of mine. It is a bit weird, because Ruby doesn't have any .insert function, Enterbrain added it to RGSS.

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.
It works for me, and all the time not only the first one.

hey vgvgf!
I really enjoy your script, but i got one problem:

when i whirl around the mouse in the screen the fps drops down to 19...
And in a shooting game, where run the 8-ways, you need to whirl the mouse around, to aim fast at plenty of enemies.
That's a problem with RPG Maker in general. I have tried whirling the mouse over the Game.exe window with and without my script, and in both cases the fps drop down. However, after changing the Game.exe proccess priority to high the fps only drop in 1 frame, insteand of in 15 frames dropped with normal priority. Or that at least happends for in my computer. Try adding f0tz!baerchen antilag script.

greetings to everybody, but mario, i hate him...^^
And who is mario? Mario the plumber who saved the Mushroom Kingdom? That's the only mario that comes to my head right now, and I hate it too, hehe.

Hello again, I've been playing around a bit more with this script, and noticed a difference in array input.

A single array still works as the return value is true when at least one of virtual keys in the array are true for the corresponding method, but sub-arrays don't work. in your old script the Sub-Arrays will have true value only when all of its values are true for the corresponding method. Now however, it returns an error:

"Cannot convert Array into Integer"

Are you planning to include support for sub-arrays again?
Are you also planning to reintroduce key combos?
I have removed the special Array Input formats, because almost nobody used them and they were a bit time consuming. However, I want to add them again, but in new separated methods. Also, I am working on a new Key Combos system, the old one didn't convinced me much, it was difficult to use, and bad coded. I will make a simple and better one for next version.


Thanks all for the support, I am currently working on this script, for adding the new functions I mentioned. Also, I am thinking on realeasing the dll sources codes, what do you think about that?
 
i try to use this for key names:
[rgss] 
GetKeyNameText = Win32API.new("user32","GetKeyNameText", 'LPI', 'I')
MapVirtualKey = Win32API.new("user32","MapVirtualKey", 'II', 'I')
#Buffer
name = " " * 256
#Den VirtualKeyCode angeben
A = 65
#Den LPARAM feststellen
a = MapVirtualKey.call(A, 0) << 16 | 1 << 24 # or without | 1 << 24
#Funktion aufrufen
GetKeyNameText.call(a, name, 256)
puts name.strip #=> A[NUL]
[/rgss]
but is doesnt fuction...
have you a idea how you can get the "localised" key?
i mean as sample
"@" if you press Q-key with right alt (alt gr)
or öäü as OEM keys

if not i try to make keyboard layouts itself
 
yeah, exactly the it's a meeee, mario!^^
and i tried fotzi's antilag script, and the problem keeps dropping the fps...
and the higher priority can'T solve the problem either.

But hey, I heard of someone around here... a programming God called vagsdh or some random name like that who might possibly solve the problem with his overwhelming skillzzzzzzz^^

Might he? ;)
 
@hanmac, see my old writting script: Aleworks Writting Lite.

@Caldaron, I will see if I can reduce the proccessing in the DLL for the next version, so it will be faster. Also, I don't belive in programming Gods, and I don't know him, but if you say, maybe he can.
 
hello again.

vgvgf, There are a few other functions from your old input module that is not present in this one that I find a use for. I have added them from your old one to this one, but was wondering if there is a faster way of doing them?

they are:

Input.activated? #for determining status of caps lock, num lock, scroll lock, and insert
Input.key_click #I renamed it to Input.trigger to simulate a key trigger
Input.key_release #I renamed to Input.release to simulate releasing a key that was pressed
Input.key_press #I renamed to Input. press to simulate pressing a key

Thank you,

Draycos Goldaryn
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top