Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Pick number a or number b?
- blakelarson19
-
24 posts
Pick number a or number b?
For my program I need the computer to pick a random number for my generator, but For certain instances I don't want it to pick a random number from 1 to 10, but rather I want it to pick randomly two numbers that are not right next to each other… ie. 3 or 5 … 7 or 9 … 1 or 6. Please help?
- jokebookservice1
-
1000+ posts
Pick number a or number b?
I don't quite understand. You can type whatever you want into the pick random block:
Am I missing something?
- piggiety
-
65 posts
Pick number a or number b?
Oh! I get it. This might work:
This is super complicated, but I hope it helps! I didn't know what the numbers were used for, so I just put in a bunch of move … steps. You can get rid of those if you want.
This is super complicated, but I hope it helps! I didn't know what the numbers were used for, so I just put in a bunch of move … steps. You can get rid of those if you want.
- blakelarson19
-
24 posts
Pick number a or number b?
Oh! I get it. This might work:
This is super complicated, but I hope it helps! I didn't know what the numbers were used for, so I just put in a bunch of move … steps. You can get rid of those if you want.
Thank you for the help, but I don't really understand this lol.
- blakelarson19
-
24 posts
Pick number a or number b?
I don't quite understand. You can type whatever you want into the pick random block:Am I missing something?
Yes, I don't want it to pick 3 to 5 I want it to pick 3 OR 5 , so I want 4 out of the picture completely.
- piggiety
-
65 posts
Pick number a or number b?
Oh! I get it. This might work:
This is super complicated, but I hope it helps! I didn't know what the numbers were used for, so I just put in a bunch of move … steps. You can get rid of those if you want.
Thank you for the help, but I don't really understand this lol.
Ha! I'm not good with simple scripts…
- blakelarson19
-
24 posts
Pick number a or number b?
Oh! I get it. This might work:
This is super complicated, but I hope it helps! I didn't know what the numbers were used for, so I just put in a bunch of move … steps. You can get rid of those if you want.
Thank you for the help, but I don't really understand this lol.
Ha! I'm not good with simple scripts…
Should I share my project would that help?
- georgeskey
-
100+ posts
Pick number a or number b?
You could simply do:
Or, to make it a little more reusable and easy,
- blakelarson19
-
24 posts
Pick number a or number b?
You could simply do:Or, to make it a little more reusable and easy,
Thank you, will the computer be able to process this quickly enough? This makes sense though and I'm trying it right now.
- georgeskey
-
100+ posts
Pick number a or number b?
And if you mean randomly pick two numbers, you can just do: You could simply do:Or, to make it a little more reusable and easy,
- zp100
-
100+ posts
Pick number a or number b?
A really easy way would be:
This will give either 3 or 5. Change the 1 at the end to a 3 to make it pick 5 or 7.
Last edited by zp100 (May 19, 2016 00:12:14)
- deck26
-
1000+ posts
Pick number a or number b?
Or change the second 2 to 3 and leave the 1 at the end alone. If you just want to pick between two numbers there's always a similar method but if doing different numbers throughout your project a custom block will be clearest. A really easy way would be:This will give either 3 or 5. Change the 1 at the end to a 3 to make it pick 5 or 7.
- zp100
-
100+ posts
Pick number a or number b?
Changing the second 2 to a 3 would make it 3 or 6. And, you could make this with a custom block. It would look like this:Or change the second 2 to 3 and leave the 1 at the end alone. If you just want to pick between two numbers there's always a similar method but if doing different numbers throughout your project a custom block will be clearest. A really easy way would be:This will give either 3 or 5. Change the 1 at the end to a 3 to make it pick 5 or 7.
Last edited by zp100 (May 20, 2016 00:01:08)
- deck26
-
1000+ posts
Pick number a or number b?
My mistake, must have been distracted! Random 2 to 3 times 2 plus 1 gives 5 or 7. Apologies for any confusion.Changing the second 2 to a 3 would make it 3 or 6. And, you could make this with a custom block. It would look like this:Or change the second 2 to 3 and leave the 1 at the end alone. If you just want to pick between two numbers there's always a similar method but if doing different numbers throughout your project a custom block will be clearest. A really easy way would be:This will give either 3 or 5. Change the 1 at the end to a 3 to make it pick 5 or 7.
- deck26
-
1000+ posts
Pick number a or number b?
If making a custom block though much easier to just use random 1 to 2 to choose first or second.
Last edited by deck26 (May 20, 2016 07:07:35)
- zp100
-
100+ posts
Pick number a or number b?
Yes, that would probably be the simplest, but my idea doesn't require a list. or
- blakelarson19
-
24 posts
Pick number a or number b?
Thanks guys for the advice, but earlier in the thread I found a solution,
- jokebookservice1
-
1000+ posts
Pick number a or number b?
Don't nest the ifs, because if Number Help = 1, it can't become 2 before the next nested if statement Thanks guys for the advice, but earlier in the thread I found a solution,
- zp100
-
100+ posts
Pick number a or number b?
It would be much easier to just do Thanks guys for the advice, but earlier in the thread I found a solution,
It would give the exact same result, but with fewer blocks and less space.
- Discussion Forums
- » Help with Scripts
-
» Pick number a or number b?