Discuss Scratch

malaika2001
Scratcher
36 posts

Pick random x position

I'm having trouble in pick random and 3 x positions. Can you help me in script?
The 3 x-positions are = -134,170 and 10 and there is a sprite of which i want to pick random from three of these x-positions.
Help me please!
drmcw
Scratcher
1000+ posts

Pick random x position

Put the 3 coordinates in a list and use
setxtoitemrandomofcoordinate list

To select a random of 3 sprites then create 3 new broadcast messages called maybe select1, select2 and select3 then use

broadcastjoinselectpickrandom1to3
malaika2001
Scratcher
36 posts

Pick random x position

I mean there's a coin and there are 3 curtains. in first round coin is in middle curtain then in second curtain its in left curtain and so on…. so i want a script like that.
drmcw
Scratcher
1000+ posts

Pick random x position

If you know where the coin is then its not random. If it is random then the broadcast is all you need. Perhaps sharing your project would explain the problem better?
malaika2001
Scratcher
36 posts

Pick random x position

drmcw wrote:

If you know where the coin is then its not random. If it is random then the broadcast is all you need. Perhaps sharing your project would explain the problem better?
No i don't know where the coin is i want it to choose randomly from 3 x-positions.
WoodenLaser
Scratcher
16 posts

Pick random x position

I think understand what you mean, the following code may help

setrandom x positiontopickrandom1to3ifrandomxposition=1thensetxto-134ifrandomxposition=2thensetxto170ifrandomxposition=3thensetxto10

Have fun coding!

Last edited by WoodenLaser (Nov. 2, 2014 06:13:55)

malaika2001
Scratcher
36 posts

Pick random x position

WoodenLaser wrote:

I think understand what you mean, the following code may help

setrandom x positiontopickrandom1to3ifrandomxposition=1thensetxto-134ifrandomxposition=2thensetxto170ifrandomxposition=3thensetxto10

Have fun coding!
Where will i find block random x position v ?
malaika2001
Scratcher
36 posts

Pick random x position

WoodenLaser wrote:

I think understand what you mean, the following code may help

setrandom x positiontopickrandom1to3ifrandomxposition=1thensetxto-134ifrandomxposition=2thensetxto170ifrandomxposition=3thensetxto10

Have fun coding!
Okay i got it thanks. We'll make a variable thanks!
malaika2001
Scratcher
36 posts

Pick random x position

malaika2001 wrote:

WoodenLaser wrote:

I think understand what you mean, the following code may help

setrandom x positiontopickrandom1to3ifrandomxposition=1thensetxto-134ifrandomxposition=2thensetxto170ifrandomxposition=3thensetxto10

Have fun coding!
Okay i got it thanks. We'll make a variable thanks!
I coded it but it stays behind only one curtain.
Here's what script i entered in that coin:
whenbackdropswitchestobackdrop2

and then the script you've entered above.

Last edited by malaika2001 (Nov. 2, 2014 11:53:09)

WoodenLaser
Scratcher
16 posts

Pick random x position

The backdrop only switches once as far as I can see, so you need to either switch the backdrop again to the same one to trigger this, or something like…
whenIreceivechange curtains
which is broadcast after one is clicked
StarGjikolli
Scratcher
55 posts

Pick random x position

malaika2001 wrote:

I'm having trouble in pick random and 3 x positions. Can you help me in script?
The 3 x-positions are = -134,170 and 10 and there is a sprite of which i want to pick random from three of these x-positions.
Help me please!
Same
StarGjikolli
Scratcher
55 posts

Pick random x position

malaika2001 wrote:

I mean there's a coin and there are 3 curtains. in first round coin is in middle curtain then in second curtain its in left curtain and so on…. so i want a script like that.
Mine is a pick the cup game. I need the prize to go at one of 3 places: x:0 y:0,x:150 y:0 and x:150 y:0
Cool_Dude2022
Scratcher
500+ posts

Pick random x position

StarGjikolli wrote:

malaika2001 wrote:

I mean there's a coin and there are 3 curtains. in first round coin is in middle curtain then in second curtain its in left curtain and so on…. so i want a script like that.
Mine is a pick the cup game. I need the prize to go at one of 3 places: x:0 y:0,x:150 y:0 and x:150 y:0

Please do not necropost.
StarGjikolli
Scratcher
55 posts

Pick random x position

WoodenLaser wrote:

I think understand what you mean, the following code may help

setrandom x positiontopickrandom1to3ifrandomxposition=1thensetxto-134ifrandomxposition=2thensetxto170ifrandomxposition=3thensetxto10

Have fun coding!
Thx

Powered by DjangoBB