about summary refs log blame commit diff stats
path: root/lua/sandborb/giblang.lua
blob: d1ab3a2da43a840331b783e3d43c9984f6bdd735 (plain) (tree)

































                                                                                                                               
local giblang = {_VERSION = "2024.07"}
local cons = {"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "z", "ch", "sh", "zh", "th"}
local vow = {"a", "e", "i", "o", "u", "y", "ee", "ai", "ae", "au"}

math.randomseed(os.time())

function giblang.rpick(t)
    return t[math.floor(math.random() * #t) + 1]
end

function giblang.syl()
    return giblang.rpick(cons) .. giblang.rpick(vow)
end

function giblang.word()
    local str = ""
    for i=1, math.floor(math.random() * 3) + 1 do
        str = str .. giblang.syl()
    end
    if math.random() > 0.2 then
        str = str .. giblang.rpick(cons)
    end
    return str
end

function giblang.speak(number_of_words)
    local words = ""
    for i=1,number_of_words do
        words = words .. giblang.word() .. " "
    end
    return words
end

return giblang