I was wondering if there is any-way to generate random letter's, like math.random()
but for letters. If there is, how would I do it? Any help appreciated.
Sorry I can't really explain any better.
heres a quick little method using string.char and ASCII characters
local rLetter = string.char(math.random(65, 90)) --gets a random upper-case letter (65 - 90 are letters in ASCII) rLetter = math.random() > .5 and rLetter:lower() or rLetter -- 50% chance of making it lowercased print(rLetter) --random letter :D
And to generate a sequence of random numbers you can use this function:
function randomLetter() local rLetter = string.char(math.random(65, 90)) rLetter = math.random() > .5 and rLetter:lower() or rLetter return rLetter end function generateRandomSequence(length) local sequence = "" for i = 1, length do sequence = sequence..randomLetter() end return sequence end local sevenNumberSequence = generateRandomSequence(7) print(sevenNumberSequence) -- BOOM