PDA

View Full Version : Link->InputA, etc.



pkmnfrk
08-01-2007, 06:55 PM
According to the documentation,


bool InputA
* True iff (sic) the player is pressing the A key. Writing to this variable
* simulates the press or release of the A key.

I have been working under the assumption that setting it to true is "key press", and false is "key release".

However, so far, I cannot set the button to released. Consider this series of events:


item script coolitem {
void run() {
//if some condition is met
Link->Warp(1,2);
}
}

ffc script coolminigame {
void run() {
Link->InputB = false;
while(true) {
//do mini game
if(Link->InputB) break;
Waitframe();
}
//Warp back
}
}

Say you have an item with the item script attached. When you use it, then you warp to a mini game screen. On the mini game screen, an FFC script takes over, and does the mini game. You then quit the mini game by hitting B, and then you're warped back to where you came from.

The problem is, the mini game will quit immediately, since even though I'm explicitly clearing the B button with "Link->InputB = false;", it's still being read as true.

Am I doing something wrong, or is this expected behaviour, or... what?

C-Dawg
08-02-2007, 11:57 AM
Well, here's a possible problem.

Your script only sets InputB to false (I think of it more like cancelling the input before it has any effect) the first tic the player is in the room. If the player holds the B button for more than one tic, it will trigger the minigame quit sequence. I think this might be your problem. The player mashes the B button to use the item and start the minigame. The minigame starts. Unless the player is precise enough that they can remove their finger from the B button in less than one tic, it will register and the game will quit.

A better solution is to use a "has released B" variable. The variable gets set when the player isn't pushing B, that is, when InputB is false on its own. Then, the minigame only quits if "has released B" is set AND the player is now pushing B.

Make sense?

pkmnfrk
08-02-2007, 07:53 PM
Hmm, I was assuming that it would do that automagically behind the scenes, based on the "simulates the press or release of a key" bit.

And, a slightly different and more efficient way of doing this (if you don't need to do anything else while waiting) is:


while(Link->InputB) Waitframe();

C-Dawg
08-02-2007, 09:02 PM
Nope, setting Input to false doesn't "release" the key. It just cancels out the input from having any effect.