Discuss Scratch

creepergamerEZ
Scratcher
15 posts

How Do I Make A Random Generator?

I Need Help Becuase I Am Making A Random Outcome Gen For A Rp Game
hakerdude909
Scratcher
18 posts

How Do I Make A Random Generator?

There's a block for generating a random number in the operators section:
(pick random (1) to (10))
To determine what number was generated for an outcome, just do the following:
if <(pick random (1) to (10)) = [#]> then

end
theosa11
Scratcher
100+ posts

How Do I Make A Random Generator?

hakerdude909 wrote:

There's a block for generating a random number in the operators section:
(pick random (1) to (10))
To determine what number was generated for an outcome, just do the following:
if <(pick random (1) to (10)) = [#]> then

end
this should work but do you need multiple outcomes or only a single
Executor_DV
Scratcher
8 posts

How Do I Make A Random Generator?

theosa11 wrote:

hakerdude909 wrote:

There's a block for generating a random number in the operators section:
(pick random (1) to (10))
To determine what number was generated for an outcome, just do the following:
if <(pick random (1) to (10)) = [#]> then

end
this should work but do you need multiple outcomes or only a single
Above is the base for one generator.
If you need one generator for multiple outcomes, use the couple below.
if <(pick random (1) to (10)) = [1]> then
say [1]

else
say [2]
end
This is used for two outcomes, almost like a random lever.

You can also stack them like this:
set [Number v] to (pick random (1) to (XXX))
if <(Numbers) = [1]> then
say [1]
end
if <(Numbers) = [2]> then
say [2]
end
You can continue as many as you have inputs as long as you have any number replacing (XXX).
You can also use a range to give you different percentages of the input that you used.

Last edited by Executor_DV (Feb. 9, 2023 19:14:35)

xRoxxanne
Scratcher
7 posts

How Do I Make A Random Generator?

Hi, there!
I understand there are many people who already answered, but I still would like to provide info

This block's purpose is randomness:
(pick random (#1) to (#2))
You see, #1 is the minimum number that can be generated. #2 is the maximum number that can be generated.

Example codes:
if <(pick random (#1) to (#2))=(#3)> then
Do stuff
end
repeat ((pick random (#1) to (#2)))
Do stuff
end

Hope this helped
Have fun, good luck coding

Powered by DjangoBB