Discuss Scratch
- Discussion Forums
- » Suggestions
- » "random" scripts
- 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.
And then {when I receive }
And then you can have random scripts.
- kayybee
-
Scratcher
1000+ 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.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.
- 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!
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!
- Discussion Forums
- » Suggestions
-
» "random" scripts
