Skip to content

Instantly share code, notes, and snippets.

@amaudy
Created May 26, 2012 09:47
Show Gist options
  • Save amaudy/2793172 to your computer and use it in GitHub Desktop.
Save amaudy/2793172 to your computer and use it in GitHub Desktop.
Random characters
function randOneChar()
local chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
output=math.random(1, #chars)
return output
end
for counter=1,10 do
print(randOneChar())
end
function randomChar(max_char)
if max_char <= 0 or max_char == '' then
max_char=6
end
local chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
local output = '';
for counter=1,max_char do
output=output..chars[math.random(1,#chars)]
end
return output
end
x = randomChar(5)
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment