LoginLogin

If a specific button is pressed within a certain amount of time do

Root / Programming Questions / [.]

StaticCloudCreated:
As you can tell from my bio i'm a newbie to all this but I do know the basics like @tags, wait, button presses, print and so on. My game involves this: If a specific button is pressed within a certain amount of time do something. The only way I could think of that could make it work is if the program could read 2 lines in different places at once. This is the only time I've gotten stumped while making a game and help would be extremely appreciated. Thanks!

Here is an example.
REPEAT
 VSYNC
 INC TIME
UNTIL BUTTON()==#[button name] OR TIME==120
IF BUTTON()==#[button name] THEN PRINT "Success" ELSE PRINT "Failure..."
In this example, 120 frames is the time window. Let's explain this. REPEAT just signifies the start of a REPEAT UNTIL loop. it loops until it reaches the end and a condition is met the loop is ended with UNTIL, which you specify the end condition(s) after. INC this just increases the specified value, nothing special. I think you can figure out IF and ELSE pretty easily.

ToadIsTheBest It works and I think I understand the code. Tysm!

ToasIsTheBest It works and I think I understand the code. Tysm!
no problem.