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.
Let me know of any errors ^^
Edit:
Updated the code ^^
*hugs*
- Zeriab
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