[Release] Random string/username generator
Posted 12-15-2018 - 01:40 AM by IcyJake
#1
Lua is one of my favorite programming languages. It's the first language I ever learned and I've made TONS of scripts with it. Now that it has been added as an official section to the forum, I've decided to release this script. It's one of the first scripts I've ever made in Lua. As you can tell by the title, all it does is, it generates a random string, or you could use it as a username.

You can use it for whatever you want. Enjoy!



Code:
local tableOne = {"a", "e", "i", "o", "u"}
local tableTwo = {"b" ,"c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"}

function randomName(length, times)
    local ap = true
    for x = 1, times do
        local result = ""
        for i = 1, length do
            if math.random(1, 2) == 1 then
                if ap then
                    ap = false
                    result = string.upper(tableOne[math.random(1, #tableOne)])
                end
                result = result .. tableTwo[math.random(1, #tableTwo)] .. tableOne[math.random(1, #tableOne)]
            else
                if ap then
                    ap = false
                    result = string.upper(tableTwo[math.random(1, #tableTwo)])
                end
                result = result .. tableOne[math.random(1, #tableOne)] .. tableTwo[math.random(1, #tableTwo)]
            end
        end
        print(result)
    end
end

randomName(3, 50)

[Image: LABkiI0.png]

1 Guest(s)