Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What is the easiest way to choose random values?

Asked by
Tesouro 407 Moderation Voter
10 years ago

I need to randomly select a color for a brick, but not any color, it has to be one of a specific list of colors. Let's say there are five colors ("color1", "color2" ...), what is the easiest way to pick one of them?

1 answer

Log in to vote
0
Answered by 10 years ago

Do

colors = {color1, color2, color3}

chosencolor = colors[math.random(1, #colors)]
0
could you explain what you did there? Tesouro 407 — 10y
0
Oh my bad... I meant math.random NovusTheory 133 — 10y
0
ok, explain plz? Tesouro 407 — 10y
0
My code above states the colors that should be chosen from and then chosencolor value is set to a randomized selection of a color inside the table NovusTheory 133 — 10y
0
ah, ok a table Tesouro 407 — 10y
Ad

Answer this question