Discuss Scratch

Themanhimself115
Scratcher
4 posts

Pick Random 1 to 10

I may be dumb about this question, but I can't seem to understand the pick random script. I've done some games using it, but can't seem to do the show and hide technique? I've tried ways to add “forever” or not. For people that are willing to help me, I'm using the top code as “When I receive.”

Thank you, Themanhimself115
scratch___user12345
Scratcher
1000+ posts

Pick Random 1 to 10

Are you saying you want it to be a 50/50 chance if it hides/shows? if so use this:
whenIreceive messageif0=pickrandom0to1thenshowelsehide
xxthepowerful
Scratcher
44 posts

Pick Random 1 to 10

For example :
whenclickedhidewaitpickrandom1to10secsshow

You can use the pick random block If for example you want something to hide and then wait a random time between for 1-10 sec and then show.
Themanhimself115
Scratcher
4 posts

Pick Random 1 to 10

My idea was mostly to make the enemy spawn at one of the four points on the map. Basically, I want it if this random doesn't do the right number, then it would try this random number, but if that number wasn't chosen, then it… etc.

link: https://scratch.mit.edu/projects/681037483/

Just go to the link and go to the enemy sprite and i guess try?

Thanks.

Last edited by Themanhimself115 (May 9, 2022 16:35:37)

deck26
Scratcher
1000+ posts

Pick Random 1 to 10

I suspect you're making the common mistake

ifpickrandom1to4=1thenelseifpickrandom1to4=2thenelseifpickrandom1to4=3then

What you should have is
setmyvartopickrandom1to4ifmyvar=1thenelseifmyvar=2thenelseifmyvar=3then

The second one only generates one random number which will have a value 1 to 4. The first generates multiple random numbers and hopes it eventually gets a match with no guarantee it will.



Last edited by deck26 (May 9, 2022 17:32:33)

KaaBEL-NOOB
Scratcher
64 posts

Pick Random 1 to 10

Do you mean choosing one of few starting positions by random index? I would recommend having list with the position values in pairs:
item 1 = x position of first spawnpoint
item 2 = y position of first spawnpoint
3 = x pos. of second
4 = y pos. of second
5 = x…
6 = y etc.
Then pick random block can even use lenght of list so you can easily add or remove new spawn positions. The position choosing script will look like this.
setindextopickrandom1tolengthofspawn pos/2*2setxtoitemindexofspawn positionssetytoitemindex+1ofspawn positionsshow
tb361
Scratcher
1 post

Pick Random 1 to 10

can someone help me i need when this sprite clicked do random 1 to 10 how do i do it
The_Imaginarium
Scratcher
1000+ posts

Pick Random 1 to 10

tb361 wrote:

can someone help me i need when this sprite clicked do random 1 to 10 how do i do it
Please create a new topic instead of posting on an existing one if you need help. But to answer your question, have a “when sprite clicked” event block set a variable to random 1 to 10 and change whatever you need according to that variable. For example,
whenthisspriteclickedsetvariabletopickrandom1to10
12435tryhgefbkudrhhc
Scratcher
25 posts

Pick Random 1 to 10

How can i use this block, It is very confusing
gsaa_711
Scratcher
1 post

Pick Random 1 to 10

ifthenpickrandomto10=1hideend

after that just arrange the blocks correctly

Last edited by gsaa_711 (April 21, 2024 08:20:09)

_-Wolf-Spirit-_
Scratcher
2 posts

Pick Random 1 to 10

I'm trying to do something where you use a list and you can put thing on the list when playing, and I need to figure out how to make it choose random 1 to the top number that is on the list.
MrKingofScratch
Scratcher
100+ posts

Pick Random 1 to 10

_-Wolf-Spirit-_ wrote:

I'm trying to do something where you use a list and you can put thing on the list when playing, and I need to figure out how to make it choose random 1 to the top number that is on the list.
itempickrandom1tolengthoflistoflist
The length of list block outputs how long the list is, or as you put it “the top number that is on the list.”
jediwolf3
Scratcher
1 post

Pick Random 1 to 10

settopickrandom1to10
Dagriffpatchfan
Scratcher
1000+ posts

Pick Random 1 to 10

say
Dagriffpatchfan
Scratcher
1000+ posts

Pick Random 1 to 10

whenstopflagclicked
bloxyandbrew
Scratcher
45 posts

Pick Random 1 to 10

deck26 wrote:

I suspect you're making the common mistake

ifpickrandom1to4=1thenelseifpickrandom1to4=2thenelseifpickrandom1to4=3then

What you should have is
setmyvartopickrandom1to4ifmyvar=1thenelseifmyvar=2thenelseifmyvar=3then

The second one only generates one random number which will have a value 1 to 4. The first generates multiple random numbers and hopes it eventually gets a match with no guarantee it will.



what this guy means is that the first one makes the deeper the ifs are, the rarer the chance, the second one always has an even chance for all of them.

Powered by DjangoBB