That's the first place I went, and how I found the Input.dir8 But there is nothing in there that mentions how to do a check for any button press.
If the player presses W when he should press Space there is no penalty. Only if he presses any of the direction keys. I want to make it so there's a penalty if he presses any button.
This post has been edited by Titanhex: Sep 12 2011, 06:48 PM
So you're saying I have to do like 150 different lines of !Input.trigger?(Input::BUTTONWHATEVER) if I want to check if the wrong button is being pressed plus one for if the right button is being pressed?
I wanted it to make a sound and force you to wait if you pressed the wrong button.
This post has been edited by Titanhex: Sep 12 2011, 08:32 PM
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
you don't need to include handling for every incorrect option, instead have something like:
CODE
unless Input.trigger?(Input::BUTTONWHATEVER) # this means unless the correct button was pressed, which means ANY other button will trigger this condition #beep here #wait here #whatever for the wrong condition else # this is in case the correct button was pressed # do something good end
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
you're telling me, it takes actually trying this out for me to remember how notorious ruby is for disliking tertiary expressions. So here it is:
Night5h4d3's Any Input Script
CODE
#============================================================================== # ** Night5h4d3's Any Input Script #------------------------------------------------------------------------------ # Date: 09/13/2011 For: Titanhex #============================================================================== # Descr: # Checks for any input other than specified, returns true if found, returns # false if the correct button is pressed, and returns "noinput" if no input # was detected. #============================================================================== module Input ANY = [Input::UP, Input::DOWN, Input::LEFT, Input::RIGHT, Input::A, Input::B, Input::C, Input::X, Input::Y, Input::Z, Input::L, Input::R, Input::SHIFT, Input::CTRL, Input::ALT, Input::F5, Input::F6, Input::F7, Input::F8, Input::F9] def self.trigger_other?(input) for i in 0...ANY.size if Input.trigger?(ANY[i]) if input == ANY[i] return false end return true end end return "noinput" end end
The way you use this is you call it like a normal input call, sort of:
CODE
if Input.trigger_other?(Input::A) == true # this is handling for incorrect input elsif Input.trigger_other?(Input::A) == "noinput" # put handling here to return up and check again else # this is handling for correct input end
And to boot, here's how you can do it with conditional branches:
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
Unfortunately not, it wouldn't be incompatible, it just wouldn't have handling for the other inputs. and whoops, fixed that. RIGHT was supposed to be Input::RIGHT.
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
Looks like I missed that too, XD fixed it in the post.
And simply put, Input.trigger is a hidden def. If I alias it, I've 2 options, call the original before the extra code, or after, doing so before would nulify my code, as the def would have returned by then. and as for before, well, how would I detect if the button was 'triggered?' Because, the code for detecting a trigger is in the same def I have aliased.
The only way of overcoming this issue would be to: A) Know the ruby code for the Input module or B) Create a new def that will call the trigger method separately on all possible inputs Reverse engineering the RGSS dll is the only way to obtain the code for the input module, which is illegal; not to mention that it is written in C/C++, which is not ruby.
Hope that explains why I have to go with method B.
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder