Pages: 1
Topic closed
Hi. I shared a program called Hieroglyphs Rock 1.0 where I have a different script to run for each letter of the alphabet pressed. The problem is, when more than one letter is pressed at a time, the scripts run simultaneously and everything gets messed up. I can't figure out how to get the sound, talk bubbles, and movements from one letter's script to stop when another letter is pressed. Thanks in advance for any help you can give me.
Offline
You need a heiarchy. In the block for "a" put "if not key b pressed or not key c pressed or not key d pressed" etc..
Then for "b" you would put "if not key c pressed or not key d pressed" etc..
And so on.
Offline
There's a quicker way...
First, make it so, when the Green Flag is clicked, it sets "variable" to 0.
Then, just do the "When [] key pressed" hat block, then an "if <variable=1>" block, and, whenever a key is pressed, it sets variable to 1, and when the key isn't pressed, it sets it to 0.
Offline
PaperMario123 wrote:
There's a quicker way...
First, make it so, when the Green Flag is clicked, it sets "variable" to 0.
Then, just do the "When [] key pressed" hat block, then an "if <variable=1>" block, and, whenever a key is pressed, it sets variable to 1, and when the key isn't pressed, it sets it to 0.
Really? I find my way to be a lot less time consuming.
I just duplicate the “ifs”.
Offline
thanks so much 4 the help!!!
Offline
hey guys i'm a new scratcher and a very visual person. could you please show me an example thank so much!!!!!!
Offline
hey, i tried what fg123 said, and it stopped me from pressing a letter while the other one is running. this is good, but could anyone possibly think of a way to have it switch to the other one and stop the first letter while it's running??? thanks so much 4 any help!!!!
Offline
When a topic is resolved, click the report button and type “Topic Resolved” then a moderator will come and close it.
For instance, I’m going to report it now, and then a moderator or Scratch Team member will be here.
Watch:
Offline
henley wrote:
When a topic is resolved, click the report button and type “Topic Resolved” then a moderator will come and close it.
For instance, I’m going to report it now, and then a moderator or Scratch Team member will be here.
Watch:
Thanks for the advice...but moderators usually wait to hear from the topic owner before they close the topic. Besides, from the last post by the owner, it sounds like there are still some issues to be resolved
Offline
iheartpeek-a-boo wrote:
hey, i tried what fg123 said, and it stopped me from pressing a letter while the other one is running. this is good, but could anyone possibly think of a way to have it switch to the other one and stop the first letter while it's running??? thanks so much 4 any help!!!!
Hmm, that could be complicated. Try:
Again, repeat as needed.
Offline
fg123, it didn't work. it didn't let me press the other letter, just like last time. any other ideas???? i have to fix this!!!!! again, thanks 4 the help.
Offline
iheartpeek-a-boo wrote:
fg123, it didn't work. it didn't let me press the other letter, just like last time. any other ideas???? i have to fix this!!!!! again, thanks 4 the help.
Really? It worked for mee...
So what you want is:
I press "a", "a" stuff happens.
If I keep holding "a" and press "b", "b" stuff happens.
If I keep holding "a", "b" and press "c", "c" stuff happens.
Is that you want?
Offline
I delt with this type of issue when writing my Hangman game.
I made a list variable for holding all the keystrokes that have been pressed.
You can see it here: http://scratch.mit.edu/projects/BoltBait/463279
Hope this helps.
Last edited by BoltBait (2011-12-20 18:26:47)
Offline
dear fg123,
nope. not working. would u share yours? maybe something's wrong. or maybe i've messed up. that's probably more likely.
Offline
Hello again. I'm going to try to be more clear about what I'm trying to do. I so appreciate everybody's help!
This is what I'd like my programming to do:
I press "a", "a" stuff happens,
I press "b" (or k or x or whatever), "a" stuff STOPS happening and "b" stuff happens (or k stuff or x stuff or whatever letter's stuff you pushed)
I'm not trying to hold down any keys while pushing others. I just want to push one letter at a time and I want the scripts for the previous letter to STOP (even if they aren't finished running) when I push a different letter.
Thanks again!
Offline
fg123 wrote:
Oh, well let me change my script a little. If in the case of holding, it takes the second button's action, right?
I don't have any programming right now that calls for holding down buttons. It works fine if one letter is pushed at a time and you wait for the scripts to run their course before you push the next letter. But my users who tested the program wanted to be able to "change their mind." For example, after pushing the "f" key, they wanted to be able to push the "o" key to see what it would do without waiting for the "f" key scripts to finish what they were doing. The way my program is now, if you push the "f" and then a few seconds later, push the "o", you will hear/see everything for both letters simultaneously.
Wow, I sure appreciate you spending time helping me solve this problem!
Offline
Topic closed
Pages: 1