Created
May 26, 2012 09:47
-
-
Save amaudy/2793172 to your computer and use it in GitHub Desktop.
Random characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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