This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mackan90096's profile picture

[Question] Getting a random string from a table?

Started by Mackan90096, 13 May 2013 - 12:12 AM
Mackan90096 #1
Posted 13 May 2013 - 02:12 AM
I'm currently testing things out and I'm wondering if you can get a random string from a table?

Like from a table:

local table = {"string1", "string2", "string3"}

And only one of those strings..

Can you do that? And if so, how?
Shnupbups #2
Posted 13 May 2013 - 02:14 AM

local table = {"string1","string2","string3")
local randomString = table[math.random(#table)]
Mackan90096 #3
Posted 13 May 2013 - 02:15 AM
Thanks :)/>