Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a random number generator that does not copy the same number
- minimouser
-
Scratcher
2 posts
How to make a random number generator that does not copy the same number
So I am working on a huge project for school (512MB Scratch file). I need to have a random number generator assign a number to each “subscript”. How would this be possible.
Last edited by minimouser (March 12, 2014 00:55:25)
- ErnieParke
-
Scratcher
1000+ posts
How to make a random number generator that does not copy the same number
I'm a bit confused about what's a subscript. Could you describe one? Also, more out of curiosity, how is your project 512 MB?
Really curious,
ErnieParke
Really curious,
ErnieParke
- EvilKat55
-
Scratcher
66 posts
How to make a random number generator that does not copy the same number
I'd suggest you make a list for all the numbers you need. that way when you hit that number, you can delete said number from the list so you can't hit it again.
Here is what I'm trying to say..
Here is what I'm trying to say..
when green flag clicked
set [Number v] to (item (random v) of [list numbersv])
say (Number) for (2) secs
delete ((Number) v) of [list v]
- minimouser
-
Scratcher
2 posts
How to make a random number generator that does not copy the same number
I'm a bit confused about what's a subscript. Could you describe one? Also, more out of curiosity, how is your project 512 MB?
Really curious,
ErnieParke
Its a quiz for spanish and I was not very efficient and I don't want to change the source code right now
Last edited by minimouser (March 12, 2014 02:15:28)
- WetSquidGirl9
-
Scratcher
2 posts
How to make a random number generator that does not copy the same number
Ok. Just an idea.
- EvilKat55
-
Scratcher
66 posts
How to make a random number generator that does not copy the same number
Phht! Sorry, I was on my sister's account accidentally…
- Par0dy
-
Scratcher
100+ posts
How to make a random number generator that does not copy the same number
512MB! THIS IS SCRATCH, DO YOU KNOW HOW BIG 512MB IS (524288KB)?
<(512MB)=(524288KB)>You're computer is probably going to crash considering it's scratch and it's 512MB. Do you mean 512 assets?
- MineBlox13
-
Scratcher
52 posts
How to make a random number generator that does not copy the same number
when green flag clicked
repeat (50)
set [Numbers v] to (pick random (0) to (10000))
insert (Numbers) at (1 v) of [list hi v]
if <[hi v] contains (Number)> then
Repeat last step
end
end
Hope this helps

- DudmasterUltra
-
Scratcher
100+ posts
How to make a random number generator that does not copy the same number
Above works, for really simple try
when green flag clickedThis will never give the same number as the last one, but it can every 3rd number it gives.
forever
repeat until <not <(output) = (prevoutput)>>
set (output) to (pick random (1) to (10))end
set (prevoutput) to (output)
- kmissioneer
-
Scratcher
67 posts
How to make a random number generator that does not copy the same number
do this to make a list of numbers in order:
OPTIONALLY, you can do this instead after you have your list of numbers:
set [counter] to [0]then, you will have a list of numbers from one to whatever. Then, you do this to pick one that has not been used:
repeat (however many random numbers you want)
change [ counter] by (1)
add [counter] to [list of unused numbers]
end
repeat until <not <[number you are currently using] = [used]>>repeat that to pick numbers
set [number you are currently using] to [(item ((pick random (1) to (length of [list of unused numbers]))v) of [list of unused numbers])]
end
replace item (number you are currently using) of [list v] with [used]
OPTIONALLY, you can do this instead after you have your list of numbers:
repeat until <(length of (list of unused numbers)) = [0]>with this, you don't have to wait teh few seconds it would take to hit-and-miss for an unused number.
set [list item being used] to (pick random (1) to (length of (list of unused numbers)))
set [active number] to (item (list item being used) of [list of unused numbers])
delete (list item being used) of (list of unused numbers)
end
Last edited by kmissioneer (March 13, 2014 16:24:29)
- typemaster
-
Scratcher
100+ posts
How to make a random number generator that does not copy the same number
First, you need to create 2 lists. One called numbers and one called use. The numbers list contains numbers 1-9. We will leave the other list empty for now. Also a variable called last. Here is the script:
Hope this helped you. Tell me if it did.
//put you trigger here
set (last) to (join (item (random) of [numbers]) (item (random) of [numbers]) )
say (last) for () secs
add [last] to [used]
forever
set (last) to (join (item (random) of [numbers]) (item (random) of [numbers]) )
if <not <[used] contains [last]>> then
say (last) for () secs
add [last] to [numbers]
end
end
//you will put as many seconds as you need
//also, you can put joins inside of each other, so put as many joins as you need digits. I just used 2 as example here
Hope this helped you. Tell me if it did.
- bigred1011
-
Scratcher
15 posts
How to make a random number generator that does not copy the same number
512MB! THIS IS SCRATCH, DO YOU KNOW HOW BIG 512MB IS (524288KB)?<(512MB)=(524288KB)>You're computer is probably going to crash considering it's scratch and it's 512MB. Do you mean 512 assets?
I've seen bigger, and it works on my laptop.
- mahdieh_asna
-
New Scratcher
21 posts
How to make a random number generator that does not copy the same number
I have a question! where are these red parts you guys used in your scripts?????
- deck26
-
Scratcher
1000+ posts
How to make a random number generator that does not copy the same number
I have a question! where are these red parts you guys used in your scripts?????Red blocks are just things that Scratchblocks doesn't recognise so someone has entered something incorrectly or deliberately indicated the space where whoever wants to use the script should insert their own code.
- sadie_coder
-
New Scratcher
1 post
How to make a random number generator that does not copy the same number
what is the red piece?
- Ataxaos
-
Scratcher
500+ posts
How to make a random number generator that does not copy the same number
what is the red piece?I noticed that you just joined less than half an hour ago…
It would be nice if you read through the whole topic before commenting! It's forum etiquette!
Literally the post above yours explains the red piece:
Red blocks are just things that Scratchblocks doesn't recognise so someone has entered something incorrectly or deliberately indicated the space where whoever wants to use the script should insert their own code.If you're posting because you didn't understand that explanation, a red piece is what happens when you make a Scratch block on the forums that doesn't actually exist in Scratch.
Like this:
obsolete!
It's best to make your own topic if you're going to ask something that has nothing to do with the title.
Finally, don't necropost! It means posting on an already resolved question, or one that hasn't seen active replies in a long while.
Try to follow these general rules as well as you can; they help make the forums run more smoothly!

- Discussion Forums
- » Help with Scripts
-
» How to make a random number generator that does not copy the same number