Discuss Scratch

fdavis
Scratcher
3 posts

"random" scripts

It sure would be nice if a “random” script was made to allow sprites to appear, move, and make choices randomly, so that it would not be necessary to add tons of scripts to one sprite to make it seem random.
Spyderblade
Scratcher
100+ posts

"random" scripts

You can use {Broadcast (pick random (1) to (10))}

And then {when I receive }

And then you can have random scripts.

“I was determined to know beans.” ~ Henry David Thoreau, Walden
kayybee
Scratcher
1000+ posts

"random" scripts

fdavis wrote:

It sure would be nice if a “random” script was made to allow sprites to appear, move, and make choices randomly, so that it would not be necessary to add tons of scripts to one sprite to make it seem random.
Well, scratch is about learning to program so you should be learning to add tons of scripts to one sprite to make it seem random instead of having the Scratch Team do it for you.
PERCE-NEIGE
Scratcher
100+ posts

"random" scripts

kayybee's right.
Failord
Scratcher
1000+ posts

"random" scripts

This is actually pretty easy. Let's say you want a 1 in 10 chance of something happening.

if <(pick random (1) to (10)) = (1)> then
occurance
end

The boolean decides randomly. You can adjust the chance, too.

For “go to a random place on the screen:”
go to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))

For “point in a random direction:”
point in direction (pick random (-179) to (180))

For “move a random amount:”
move (pick random (1) to (10)) steps
or
change x by (pick random (1) to (10)) etc.

You get the idea. Scratch on!

Thanks for the ride, Scratch Team and community! Unfortunately, the time has come for me to move on from Scratch, so I'll no longer be using the forums. Thanks again, and farewell!
Invisible text! This will show you if a profile I claim to be mine IS mine. Just remember to visit the profile and see if I confirmed in the comments.
For old time's sake, see the revolutionary Laser Battle 2.0! Also see Unstoppable Game!

And no, the evil kumquats didn't alter my signature…

Powered by DjangoBB