This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-09-18 13:24:15

dudesonface
New Scratcher
Registered: 2010-09-17
Posts: 6

help plz - press & hold / release events

can anyone enlighten me how to create a trigger loop

that starts when a specific key is held down, and stops when that key is released?
im kinda losing my edge right now.

ty any input apreciated

Offline

 

#2 2010-09-18 13:27:16

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: help plz - press & hold / release events

[blocks]
<when green flag clicked>
<forever>
<if><key[ (whatever key you want to trigger it) ]pressed?>
--Put here what you want to do while the key is pressed.
<else>
--Put here what you want to do when it is not pressed.
<end>
<end>
[/blocks]
OR
[blocks]
<when green flag clicked>
<forever>
   <wait until> <key[ (whichever key you want) ]pressed?>
   <repeat until> <not> <key[ (whichever key you want) ]pressed?> >>
--Stuff you wanna do while it's pressed
   <end>
--Stuff you wanna do after the key is not pressed.
<end>
[/blocks]

Last edited by Kingdaro (2010-09-18 13:32:33)

Offline

 

#3 2010-09-18 13:28:18

kwickgamer
Scratcher
Registered: 2010-07-13
Posts: 42

Re: help plz - press & hold / release events

Try:

Repeat until (Not(key pressed))
loop content
end repeat


Kwickgamer Classic Collection! What is it? find out here!

Offline

 

#4 2010-09-18 13:54:28

dudesonface
New Scratcher
Registered: 2010-09-17
Posts: 6

Re: help plz - press & hold / release events

well in that case i think i have found a bug in the program.

following trigger:

event: press O
condition: variable(X)=1
action: do blablabla

now, i have the state of the variable(x) indicated in the screen, and its 0.
however by pressing O the trigger is executed, ignoring the condition.

what could i possibly have overseen?

Offline

 

#5 2010-09-18 14:04:53

dudesonface
New Scratcher
Registered: 2010-09-17
Posts: 6

Re: help plz - press & hold / release events

oh nevermind  smile  sry gods of scratch i missed a little block that was out of place messing up the entire chain of actions. ty for the help so far!

Offline

 

Board footer