A squeak hack for (key pressed) would help so many users in their type-based projects. I requested one from nxIII, but it didn't quite work.
If any other advanced squeak hackers can help me out here, it would be greatly appreciated. Thanks!
Offline
He's not talking about <key [space] pressed>; he's talking about <key pressed>.
Offline
What JonathanPB said, but like a variable (key pressed --> ) <--
Offline
I've worked this into streak...
However, in the mean time you can do thia uaing BYOB - just make the block a boolean reporter, and have it report a loooooooonnnnnnnggggg boolean expression which evaluates whether any key is pressed using many many nested OR blocks.
Offline
billyedward wrote:
I've worked this into streak...
However, in the mean time you can do thia uaing BYOB - just make the block a boolean reporter, and have it report a loooooooonnnnnnnggggg boolean expression which evaluates whether any key is pressed using many many nested OR blocks.
That's a good idea, but I would like to be able to upload any projects that might include this to the Scratch website. Also, it is meant to read WHAT key is being pressed. For
example, if you pressed the space key and had a script that said
set variable to (key pressed), the variable would read
"space". Thanks though.
Offline
shadow_7283 wrote:
billyedward wrote:
I've worked this into streak...
However, in the mean time you can do thia uaing BYOB - just make the block a boolean reporter, and have it report a loooooooonnnnnnnggggg boolean expression which evaluates whether any key is pressed using many many nested OR blocks.That's a good idea, but I would like to be able to upload any projects that might include this to the Scratch website. Also, it is meant to read WHAT key is being pressed. For
example, if you pressed the space key and had a script that said
set variable to (key pressed), the variable would read
"space". Thanks though.
That complicates things... you could probably still do that in BYOB, just have an internal variable whichs sets to it, ill give it a go.
Offline
There you go! Made it in BYOB though.
Offline
nXIII wrote:
Mine should have worked, bu it didn't...
How did you make it? Did you try to do it in the browser part?
Offline
Bump
Offline
shadow_7283 wrote:
Bump
Try that http://www.mediafire.com/?0zz4l3yggvj
Offline
markyparky56 wrote:
shadow_7283 wrote:
Bump
Try that http://www.mediafire.com/?0zz4l3yggvj
It's really great, I just wish we could put it into Scratch....
Offline
shadow_7283 wrote:
markyparky56 wrote:
shadow_7283 wrote:
Bump
Try that http://www.mediafire.com/?0zz4l3yggvj
It's really great, I just wish we could put it into Scratch....
Yeah...
Offline
Wouldn't this work?
[blocks]
<when green flag clicked>
<set{ Key Pressed }to( None
<when[ Space ]key pressed>
<set{ Key Pressed }to( Space
<wait until><< <not> <key[ Space ]pressed?> >>
<set{ Key Pressed }to( None
<when[ A ]key pressed>
<set{ Key Pressed }to( A
<wait until><< <not> <key[ A ]pressed?> >>
<set{ Key Pressed }to( None
... Make a whole lot more scripts like this for different keys ...
<when[ Z ]key pressed>
<set{ Key Pressed }to( Z
<wait until><< <not> <key[ Z ]pressed?> >>
<set{ Key Pressed }to( None
[/blocks]
It will only work for one key at a time...but maybe that is sufficient for what you want?
Offline
Paddle2See wrote:
Wouldn't this work?
[blocks]
<when green flag clicked>
<set{ Key Pressed }to( None
<when[ Space ]key pressed>
<set{ Key Pressed }to( Space
<wait until><< <not> <key[ Space ]pressed?> >>
<set{ Key Pressed }to( None
<when[ A ]key pressed>
<set{ Key Pressed }to( A
<wait until><< <not> <key[ A ]pressed?> >>
<set{ Key Pressed }to( None
... Make a whole lot more scripts like this for different keys ...
<when[ Z ]key pressed>
<set{ Key Pressed }to( Z
<wait until><< <not> <key[ Z ]pressed?> >>
<set{ Key Pressed }to( None
[/blocks]
It will only work for one key at a time...but maybe that is sufficient for what you want?
Thats kind of what i did, but i bundled it all into one block using Byob.
Offline
Paddle2See wrote:
Wouldn't this work?
[blocks]
<when green flag clicked>
<set{ Key Pressed }to( None
<when[ Space ]key pressed>
<set{ Key Pressed }to( Space
<wait until><< <not> <key[ Space ]pressed?> >>
<set{ Key Pressed }to( None
<when[ A ]key pressed>
<set{ Key Pressed }to( A
<wait until><< <not> <key[ A ]pressed?> >>
<set{ Key Pressed }to( None
... Make a whole lot more scripts like this for different keys ...
<when[ Z ]key pressed>
<set{ Key Pressed }to( Z
<wait until><< <not> <key[ Z ]pressed?> >>
<set{ Key Pressed }to( None
[/blocks]
It will only work for one key at a time...but maybe that is sufficient for what you want?
It's a great method, but the only reason I went to the trouble of posting a topic asking for a hack is to avoid all these scripts. Using it you could shorten 52 scripts to 1. Thanks though!
Offline
Chrischb wrote:
That senses clicking...
![]()
HUH?
Offline
If you want, just make a new method that is this
(Sensor keyPressed: (self asciiFor: 'a')) ifTrue: [^ 'a']. (Sensor keyPressed: (self asciiFor: 'b')) ifTrue: [^ 'b']. ...
type thing.
Offline
nXIII wrote:
If you want, just make a new method that is this
Code:
(Sensor keyPressed: (self asciiFor: 'a')) ifTrue: [^ 'a']. (Sensor keyPressed: (self asciiFor: 'b')) ifTrue: [^ 'b']. ...type thing.
Type at where?
Offline
nXIII wrote:
If you want, just make a new method that is this
Code:
(Sensor keyPressed: (self asciiFor: 'a')) ifTrue: [^ 'a']. (Sensor keyPressed: (self asciiFor: 'b')) ifTrue: [^ 'b']. ...type thing.
I tried putting that under the KeyPressed section you made on your last attempt and did not change the block specs, but now all I'm getting is aScratchStageMorph() as its value...
Edit: That's weird... It senses numbers but not letters...
Last edited by shadow_7283 (2010-04-03 11:02:49)
Offline
You could just stack up or blocks like this: [blocks]
<< << <or> >> <or> << <or> >> >> [/blocks] ect.
Offline
MaxtheWeirdo wrote:
You could just stack up or blocks like this: [blocks]
<< << <or> >> <or> << <or> >> >> [/blocks] ect.
Thats what i did for the byob block, just hid it all away.
Offline