Discuss Scratch

thundershock51
New Scratcher
4 posts

help with randomlly picking between 2 specific numbers

ok so, what i want is a way to make it so that, when a sprite spawns, it go to 1 of 2 SPECIFIC points (e.g either y-220 or y220),
(pick random () to (10)) picks ANY number between to given numbers, so that doesn't work.

if you know a way, tell me in the replys, thanks!

Last edited by thundershock51 (Sept. 10, 2020 14:56:30)

SpaceBoy234
Scratcher
78 posts

help with randomlly picking between 2 specific numbers

Would this work?

if <(pick random (1) to (2)) = [1]> then
set y to (-220)
else
set y to (220)
end

Or for the 1-line way:
(join (letter (1) of (pick random (-1) to (0))) [220])

Last edited by SpaceBoy234 (Sept. 10, 2020 15:05:26)

deck26
Scratcher
1000+ posts

help with randomlly picking between 2 specific numbers

SpaceBoy234 wrote:

Would this work?

if <(pick random (1) to (2)) = [1]> then
set y to (-220)
else
set y to (220)
end

Or for the 1-line way:
(join (letter (1) of (pick random (-1) to (0))) [220])
I'm not a fan of using join to make a negative number.

set y to ([-220] + ((pick random (0) to (1)) * [440])
-Obelisk-
Scratcher
17 posts

help with randomlly picking between 2 specific numbers

You could make a list with the two numbers, then make a script like this:
set [variable v] to (item ( (pick random (1) to (2)) of [list v] :: list))
thundershock51
New Scratcher
4 posts

help with randomlly picking between 2 specific numbers

SpaceBoy234 wrote:

Would this work?

if <(pick random (1) to (2)) = [1]> then
set y to (-220)
else
set y to (220)
end

Or for the 1-line way:
(join (letter (1) of (pick random (-1) to (0))) [220])

Thanks man! this was exactly what i wanted!
cosmosaura
Scratch Team
1000+ posts

help with randomlly picking between 2 specific numbers

Topic closed to stop future necroposts.

Powered by DjangoBB