Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Pick number a or number b?
- blakelarson19
-
24 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,if <touching [D1 v] ?> then
set [Numer Help v] to [(pick random (1) to (2)) ]
if <(Number Help) = [1]> then
set [Wolf Direction v] to [2 ]
if <(Number Help) = [2]> then
set [Wolf Direction v] to [4]
end
end
endif <touching [D1 v] ?> thenIt would give the exact same result, but with fewer blocks and less space.
set [Numer Help v] to ((pick random (1) to (2)) * (2))
end
That is true, and a good idea, unfortunately I already spent hours using the other one into my entire code.
- Mole_Gaming
-
100+ posts
Pick number a or number b?
define Pick either (a) or (b)
set [output v] to ((b) + (((a)-(b))*(pick random (0) to (1))))
Last edited by Mole_Gaming (May 20, 2016 19:37:30)
- zp100
-
100+ posts
Pick number a or number b?
That's what I said earlier.define Pick either (a) or (b)
set [output v] to ((b) + (((a)-(b))*(pick random (0) to (1))))
- Dan0510
-
100+ posts
Pick number a or number b?
Hello!
Another solution for the problem could also be

Another solution for the problem could also be
(letter (pick random (1) to (2)) of [37])That's the easiest solution I can imagine, it doesn't even require much math, but works for one digit numbers only

Last edited by Dan0510 (May 23, 2016 08:58:46)
- deck26
-
1000+ posts
Pick number a or number b?
True, it's more limited, but it's a nice alternative and potentially useful for choosing between more than 2 values. Hello!
Another solution for the problem could also be(letter (pick random (1) to (2)) of [37])That's the easiest solution I can imagine, it doesn't even require much math, but works for one digit numbers only
- Mole_Gaming
-
100+ posts
Pick number a or number b?
But this is a more simplified and easier-to-use version That's what I said earlier.
- MegaMiner260
-
6 posts
Pick number a or number b?
I also had this sort of problem. one solution is to set it from 2 random numbers not having anything to do with 3 or 5, like this:
I hope it helps
when I receive [ whatever it needs v]
set [variable v] to (pick random (30) to (31))
if <[variable] = [30]> then
set [variable v] to [3]
else
if <[variable] = [31]> then
set [variable v] to [5]
end
end
I hope it helps
- MegaMiner260
-
6 posts
Pick number a or number b?
I also had this sort of problem. one solution is to set it from 2 random numbers not having anything to do with 3 or 5, like this:
I hope it helps
when I receive [ whatever it needs v]
set [variable v] to (pick random (30) to (31))
if <[variable] = [30]> then
set [variable v] to [3]
else
if <[variable] = [31]> then
set [variable v] to [5]
end
end
I hope it helps
- Harakou
-
1000+ posts
Pick number a or number b?
Thanks for offering your help, but this thread already has quite a few suggested solutions and it's well over a year old. I don't think an answer is necessary anymore. Please check the date and make sure the thread is still relevant before replying. Thanks!
- Discussion Forums
- » Help with Scripts
-
» Pick number a or number b?