about summary refs log tree commit diff stats
path: root/lua/sandborb/giblang.lua
blob: d1ab3a2da43a840331b783e3d43c9984f6bdd735 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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