Posted 14 May 2013 - 01:05 PM
hello guys i have a question that how to make a string generator. Like in video games.
function stringGen(lenght)
parts = {"a", "b", "c", "d"} --you can add more
function genNumb()
return math.random(1, #parts)
end
output = {}
for u = 1, lenght do
table.insert(output, parts[genNumb()])
end
return table.concat(output)
end
local function generate(len)
local str=""
for i=1,tonumber(len) or 1 do
str=str..string.char(math.random(33, 126))
end
return str
end