Don't know about any of you, but I would be able to do a lot more if there was a block like this:
if for secs
Because without it you couldn't make a game where if the right arrow key is held down for two seconds then something happens, but if it's held down for less than that nothing happens.
Offline
Sonickyle wrote:
You Could Use Varibles For This, But I Support.
![]()
How?
Offline
ProgrammingAddict wrote:
Sonickyle wrote:
You Could Use Varibles For This, But I Support.
![]()
How?
if <[Right Arrow v] pressed>
wait 2 secs
if <[Right Arrow v] pressed> --(This checks if its still pressed after two secconds)
code here -- script to do what u wanna do
Offline
DigiTechs wrote:
ProgrammingAddict wrote:
Sonickyle wrote:
You Could Use Varibles For This, But I Support.
![]()
How?
if <[Right Arrow v] pressed>
wait 2 secs
if <[Right Arrow v] pressed> --(This checks if its still pressed after two secconds)
code here -- script to do what u wanna do
Yeah, but you'd need a forever block around it, and that would cause it to wait 2 secs, do whatever you want for 2 secs, and then wait for 2 secs again, and then whatever you want again, and then... well I think you get the message.
Although maybe something like this?
<when green flag clicked>
<forever>
<if><< <not> <key[ right arrow ]pressed?> >>
<wait until><key[ right arrow ]pressed?>
<wait( 2 )secsc>
<forever if><key[ right arrow ]pressed?>
whatever you want
<end>
Would still be easier if there was the block I suggested, as I doubt absolute beginners would figure that out!
Offline
This way works too, and is pretty easy:
Last edited by hmnwilson (2011-08-29 15:05:51)
Offline
hmnwilson:
Yes, but wouldn't that just constantly reset the timer. I mean the bit where it says
<forever>
<if><key[ space ]pressed?>
<reset timer>
<end>
<end>
Offline
ProgrammingAddict wrote:
hmnwilson:
Yes, but wouldn't that just constantly reset the timer. I mean the bit where it says
<forever>
<if><key[ space ]pressed?>
<reset timer>
<end>
<end>
No, it wouldn't.
Offline
ProgrammingAddict wrote:
hmnwilson:
Yes, but wouldn't that just constantly reset the timer. I mean the bit where it says
<forever>
<if><key[ space ]pressed?>
<reset timer>
<end>
<end>[/blocks]
That script right there would, yes, but not if you add the wait/if blocks. Granted, it does mean you can't use the timer for anything else, but you can make one with a variable if needed.
Offline