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.

[RMVX] Reintroducing the Button Input Process known from RMXP

Zeriab

Sponsor

For some queer reason the Button Input Process event command was removed from RMVX.
I have no idea why they would remove such a useful command. Anyway thanks to Despain requesting eventers now have a way of duplicating the effect :3
Note: This changes the way script calls in events work to the way they worked in RMXP. When the script evaluates to false it will wait a frame and then call the script again. It will do so until the script call returns something other than false.
This means that if you use something like $game_switches[23] = false then the event will appear to freeze.
Update - The script now check for FalseClass instead of false which should reduce the chance of freeze happening by accident.
Instructions on how to use it is in the header.
Code:
=begin
Button processing for script calls
Author: Zeriab
Last Modified 21st of June 2008.
Version 2.0

Allow the use of the Button Input Process command as known from RMXP
Put this in a call script:

  button_input_process(4)

In this case the variable with id 4 will be changed to the input number.
The event will halt until an button is triggered, just like with RMXP.
Change the 4 to another number to store the input in a different variable.

You can also retrieve a wider range of numbers:

  button_input_process(4, true)
  
It will now get F5-F9 and Shift, Ctrl and Alt long in new values.

= Version 2.0 additions =

  button_trigger(14)
  button_press(14)
  button_repeat(14)

The 3 new commands all work similar.
The 14 means button X (It is set to A by default)
Look in the tabel below for finding out which number correspond to which button.
The event will halt until the specified button is triggered/pressed/repeated.
Note that I have experience some problems with the repeat button not
working properly when it is a special key such as Shift.
  
Here are what the different numbers mean: (Defaults in ())
2 - down
4 - left
6 - right
8 - up
11 - A (Shift)
12 - B (Esc, Num 0, X)
13 - C (Space, Enter, Z)
14 - X (A)
15 - Y (Y)
16 - Z (Z)
17 - L (L)
18 - R (W)

If you use the extended version you also have these to consider.
21 - SHIFT
22 - CTRL
23 - ALT
25 - F5
26 - F6
27 - F7
28 - F8
29 - F9

Note: By default shift is both 11 and 21. The number has priority.
=end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Script (Overwrites it to include the eval(script) = false => wait, RMXP)
  #--------------------------------------------------------------------------
  def command_355
    script = @list[@index].parameters[0] + "\n"
    loop do
      if @list[@index+1].code == 655        # Second line of script and after
        script += @list[@index+1].parameters[0] + "\n"
      else
        break
      end
      @index += 1
    end
    if (eval(script) == FalseClass)
      return false
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Button Input
  #--------------------------------------------------------------------------
  def button_input_process(n, all = false)
    @button_input_variable_id = n
    # Process the input button
    input_button(all)
    # If a button where pressed
    if @button_input_variable_id == 0
      # Proceed
      return true
    end
    # Wait
    return FalseClass
  end
  #--------------------------------------------------------------------------
  # * Button Input
  #--------------------------------------------------------------------------
  def input_button(all)
    # Determine pressed button
    n = 0
    range = all ? 1..29 : 1..18
    for i in range
      if Input.trigger?(i)
        n = i
      end
    end
    # If button was pressed
    if n > 0
      # Change value of variables
      $game_variables[@button_input_variable_id] = n
      $game_map.need_refresh = true
      # End button input
      @button_input_variable_id = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Wait for button to be triggered
  #--------------------------------------------------------------------------
  def button_trigger(id)
    if Input.trigger?(id)
      return true
    end
    return FalseClass
  end
  #--------------------------------------------------------------------------
  # * Wait for button to be pressed
  #--------------------------------------------------------------------------
  def button_press(id)
    if Input.press?(id)
      return true
    end
    return FalseClass
  end
  #--------------------------------------------------------------------------
  # * Wait for button to be repeat
  #--------------------------------------------------------------------------
  def button_repeat(id)
    if Input.repeat?(id)
      return true
    end
    return FalseClass
  end
end

Let me know of any errors ^^

Edit:
Updated the code ^^

*hugs*
- Zeriab
 
* came here just for the hug :D *

I was close to requesting something like this as well.  A quick check, and you just saved my li'l tiny side project for another few weeks :)
 

Zeriab

Sponsor

I hope you enjoyed the hug :D

I am glad you are able to use it. If you run into any problems don't hesitate to tell me ^^
 
In VX, in the Conditional Branch option, on the last page there is a "___ Button is Pressed" option. That basically works the like the Input Processing thing.
 
SaiyanKirby":2h69rhr1 said:
In VX, in the Conditional Branch option, on the last page there is a "___ Button is Pressed" option. That basically works the like the Input Processing thing.

Yep. This pretty much replaces input processing (just put it in a loop). Only catch is you can't use the 1, 2, 3, etc. keys but you couldn't in RMXP either.
 
But Button Input Processing is a lot easier if you want something like button mashing. It pauses until you press down a key, whereas "If Button is Pressed" has to be placed in a loop to work like it.
 

Zeriab

Sponsor

I have made a fairly big update which I am sure some of you eventers will enjoy :3

You can now make an event halt until a specific button is triggered/pressed/repeated.
Think of the uses, think of how much easier certain types of system becomes. The instructions are in the header of the script (look in the first post)

I have also changed the detection system of whether the script call should be repeated or not. It now requires the evaluation of the script to return FalseClass (or false.class) instead of false. This should decrease the chance of you making your game freeze by accident.

Also note that the script calls must be just one line. Not two or it won't work.

*hugs*
- Zeriab
 

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