По поводу gsub

Fuexie

Известный
Автор темы
108
30
Помогите быдлокодеру

Lua:
function _seperate(_0)
    if string.find(_0,'%d') then
        local _1, _2, _3, _4, _5 = tostring(_0), tostring(_0), tostring(_0), tostring(_0), tostring(_0)
        for k, v in pairs(colourNum) do
            _1 = _1:gsub(k, v)
        end
        for k, v in pairs(halfNum) do
            _2 = _2:gsub(k, v)
        end
        for k, v in pairs(dozenNum) do
            _3 = _3:gsub(k, v)
        end
        for k, v in pairs(columnNum) do
            _4 = _4:gsub(k, v)
        end
        for k, v in pairs(evennessNum) do
            _5 = _5:gsub(k, v)
        end
        return _1, _2, _3, _4, _5
    else
        return nil
    end
end

Lua:
function _cmd_gen()
    math.randomseed(os.time())
    local _r = math.random(0,36)
    local colour, half, dozen, column, evenness = _seperate(_r)
    slm('Попробуйте: '  .._r.. ' | Colour: ' ..colour.. ' | Half: ' ..half.. ' | Дюжина: ' ..dozen.. ' | Столбец: ' ..column.. ' | Чёт/Нечет: ' ..evenness,-1)
end
Возвращает такую залупу:
Код:
Попробуйте: 17 | Colour: {d8{5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}}Black{ffffff}114}Red{ffffff}{d{5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}}Black{ffffff}{5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}}Black{ffffff}{d8{5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d82114}Red{ffffff}14}Red{ffffff}5{d8{d821
Вот таблицы, знаю залупа, и вообще пидороблядина, но надеюсь на помощь, и подсказку как оптимизировать эту хуйню.
Lua:
local colourNum = {
    ["0"] = "{60d815}Green{ffffff}",
    ["1"] = "{d82114}Red{ffffff}",
    ["2"] = "{595959}Black{ffffff}",
    ["3"] = "{d82114}Red{ffffff}",
    ["4"] = "{595959}Black{ffffff}",
    ["5"] = "{d82114}Red{ffffff}",
    ["6"] = "{595959}Black{ffffff}",
    ["7"] = "{d82114}Red{ffffff}",
    ["8"] = "{595959}Black{ffffff}",
    ["9"] = "{d82114}Red{ffffff}",
    ["10"] = "{595959}Black{ffffff}",
    ["11"] = "{595959}Black{ffffff}",
    ["12"] = "{d82114}Red{ffffff}",
    ["13"] = "{595959}Black{ffffff}",
    ["14"] = "{d82114}Red{ffffff}",
    ["15"] = "{595959}Black{ffffff}",
    ["16"] = "{d82114}Red{ffffff}",
    ["17"] = "{595959}Black{ffffff}",
    ["18"] = "{d82114}Red{ffffff}",
    ["19"] = "{d82114}Red{ffffff}",
    ["20"] = "{595959}Black{ffffff}",
    ["21"] = "{d82114}Red{ffffff}",
    ["22"] = "{595959}Black{ffffff}",
    ["23"] = "{d82114}Red{ffffff}",
    ["24"] = "{595959}Black{ffffff}",
    ["25"] = "{d82114}Red{ffffff}",
    ["26"] = "{595959}Black{ffffff}",
    ["27"] = "{d82114}Red{ffffff}",
    ["28"] = "{595959}Black{ffffff}",
    ["29"] = "{595959}Black{ffffff}",
    ["30"] = "{d82114}Red{ffffff}",
    ["31"] = "{595959}Black{ffffff}",
    ["32"] = "{d82114}Red{ffffff}",
    ["33"] = "{595959}Black{ffffff}",
    ["34"] = "{d82114}Red{ffffff}",
    ["35"] = "{595959}Black{ffffff}",
    ["36"] = "{d82114}Red{ffffff}"
}
local halfNum = {
    ["0"] = "zero",
    ["1"] = "1 to 18",
    ["2"] = "1 to 18",
    ["3"] = "1 to 18",
    ["4"] = "1 to 18",
    ["5"] = "1 to 18",
    ["6"] = "1 to 18",
    ["7"] = "1 to 18",
    ["8"] = "1 to 18",
    ["9"] = "1 to 18",
    ["10"] = "1 to 18",
    ["11"] = "1 to 18",
    ["12"] = "1 to 18",
    ["13"] = "1 to 18",
    ["14"] = "1 to 18",
    ["15"] = "1 to 18",
    ["16"] = "1 to 18",
    ["17"] = "1 to 18",
    ["18"] = "1 to 18",
    ["19"] = "19 to 36",
    ["20"] = "19 to 36",
    ["21"] = "19 to 36",
    ["22"] = "19 to 36",
    ["23"] = "19 to 36",
    ["24"] = "19 to 36",
    ["25"] = "19 to 36",
    ["26"] = "19 to 36",
    ["27"] = "19 to 36",
    ["28"] = "19 to 36",
    ["29"] = "19 to 36",
    ["30"] = "19 to 36",
    ["31"] = "19 to 36",
    ["32"] = "19 to 36",
    ["33"] = "19 to 36",
    ["34"] = "19 to 36",
    ["35"] = "19 to 36",
    ["36"] = "19 to 36"
}
local dozenNum = {
    ["0"] = "zero",
    ["1"] = "1st 12",
    ["2"] = "1st 12",
    ["3"] = "1st 12",
    ["4"] = "1st 12",
    ["5"] = "1st 12",
    ["6"] = "1st 12",
    ["7"] = "1st 12",
    ["8"] = "1st 12",
    ["9"] = "1st 12",
    ["10"] = "1st 12",
    ["11"] = "1st 12",
    ["12"] = "1st 12",
    ["13"] = "2nd 12",
    ["14"] = "2nd 12",
    ["15"] = "2nd 12",
    ["16"] = "2nd 12",
    ["17"] = "2nd 12",
    ["18"] = "2nd 12",
    ["19"] = "2nd 12",
    ["20"] = "2nd 12",
    ["21"] = "2nd 12",
    ["22"] = "2nd 12",
    ["23"] = "2nd 12",
    ["24"] = "2nd 12",
    ["25"] = "3rd 12",
    ["26"] = "3rd 12",
    ["27"] = "3rd 12",
    ["28"] = "3rd 12",
    ["29"] = "3rd 12",
    ["30"] = "3rd 12",
    ["31"] = "3rd 12",
    ["32"] = "3rd 12",
    ["33"] = "3rd 12",
    ["34"] = "3rd 12",
    ["35"] = "3rd 12",
    ["36"] = "3rd 12"
}
local columnNum = {
    ["0"] = "zero",
    ["1"] = "3 to 1 1st",
    ["2"] = "3 to 1 2nd",
    ["3"] = "3 to 1 3rd",
    ["4"] = "3 to 1 1st",
    ["5"] = "3 to 1 2nd",
    ["6"] = "3 to 1 3rd",
    ["7"] = "3 to 1 1st",
    ["8"] = "3 to 1 2nd",
    ["9"] = "3 to 1 3rd",
    ["10"] = "3 to 1 1st",
    ["11"] = "3 to 1 2nd",
    ["12"] = "3 to 1 3rd",
    ["13"] = "3 to 1 1st",
    ["14"] = "3 to 1 2nd",
    ["15"] = "3 to 1 3rd",
    ["16"] = "3 to 1 1st",
    ["17"] = "3 to 1 2nd",
    ["18"] = "3 to 1 3rd",
    ["19"] = "3 to 1 1st",
    ["20"] = "3 to 1 2nd",
    ["21"] = "3 to 1 3rd",
    ["22"] = "3 to 1 1st",
    ["23"] = "3 to 1 2nd",
    ["24"] = "3 to 1 3rd",
    ["25"] = "3 to 1 1st",
    ["26"] = "3 to 1 2nd",
    ["27"] = "3 to 1 3rd",
    ["28"] = "3 to 1 1st",
    ["29"] = "3 to 1 2nd",
    ["30"] = "3 to 1 3rd",
    ["31"] = "3 to 1 1st",
    ["32"] = "3 to 1 2nd",
    ["33"] = "3 to 1 3rd",
    ["34"] = "3 to 1 1st",
    ["35"] = "3 to 1 2nd",
    ["36"] = "3 to 1 3rd"
}
local evennessNum = {
    ["0"] = "zero",
    ["1"] = "ODD",
    ["2"] = "EVEN",
    ["3"] = "ODD",
    ["4"] = "EVEN",
    ["5"] = "ODD",
    ["6"] = "EVEN",
    ["7"] = "ODD",
    ["8"] = "EVEN",
    ["9"] = "ODD",
    ["10"] = "EVEN",
    ["11"] = "ODD",
    ["12"] = "EVEN",
    ["13"] = "ODD",
    ["14"] = "EVEN",
    ["15"] = "ODD",
    ["16"] = "EVEN",
    ["17"] = "ODD",
    ["18"] = "EVEN",
    ["19"] = "ODD",
    ["20"] = "EVEN",
    ["21"] = "ODD",
    ["22"] = "EVEN",
    ["23"] = "ODD",
    ["24"] = "EVEN",
    ["25"] = "ODD",
    ["26"] = "EVEN",
    ["27"] = "ODD",
    ["28"] = "EVEN",
    ["29"] = "ODD",
    ["30"] = "EVEN",
    ["31"] = "ODD",
    ["32"] = "EVEN",
    ["33"] = "ODD",
    ["34"] = "EVEN",
    ["35"] = "ODD",
    ["36"] = "EVEN"
}

З.Ы. Я понял почти в чём трабл, он определяет допустим 3 и 6 как два разных числа, а не как 36, и как эту залупу пофиксить? Никак?
 
Последнее редактирование: