少し前にluaを始めた初心者なのですが、条件分岐について詳しく知りたいので質問させていただきます。

とあるプログラムを書いていたところ下記のようなことをさせたいと思ったのですが、そのままifなどで書くと凄まじい長さになったしまうので何かいい方法はないでしょうか?

引数が1の時はA
2の時はAとB
3の時はAとBとC
4の時はAとBとCとD…
と言った感じです。
ただし実際はAとかBとかといった部分に規則性がありません。

今のコードは以下のものです。

color_set1 = colors.combine(colors.white)
color_set2 = colors.combine(colors.white, colors.orange)
color_set3 = colors.combine(colors.white, colors.orange, colors.magenta)
color_set4 = colors.combine(colors.white, colors.orange, colors.magenta, colors.lightBlue)
color_set5 = colors.combine(colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow)
color_set6 = colors.combine(colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime)


function RS(nmb)
    local cmd = {}
    cmd["1"] = "\"left\",color_set1"
    cmd["2"] = "\"left\",color_set2"
    cmd["3"] = "\"left\",color_set3"
    cmd["4"] = "\"left\",color_set4"
    cmd["5"] = "\"left\",color_set5"
    cmd["6"] = "\"left\",color_set6"
    cmd["7"] = "\"top\",color_set1"
    cmd["8"] = "\"top\",color_set2"
    cmd["9"] = "\"top\",color_set3"
    cmd["10"] = "\"top\",color_set4"
    cmd["11"] = "\"top\",color_set5"
    cmd["12"] = "\"top\",color_set6"
    cmd["13"] = "\"back\",color_set1"
    cmd["14"] = "\"back\",color_set2"
    cmd["15"] = "\"back\",color_set3"
    cmd["16"] = "\"back\",color_set4"
    cmd["17"] = "\"back\",color_set5"
    cmd["18"] = "\"back\",color_set6"
    cmd["19"] = "\"bottom\",color_set1"
    cmd["20"] = "\"bottom\",color_set2"
    cmd["21"] = "\"bottom\",color_set3"
    cmd["22"] = "\"bottom\",color_set4"
    cmd["23"] = "\"bottom\",color_set5"
    cmd["24"] = "\"bottom\",color_set6"
    cmd["25"] = "\"front\",color_set1"
    cmd["26"] = "\"front\",color_set2"
    cmd["27"] = "\"front\",color_set3"
    cmd["28"] = "\"front\",color_set4"
    cmd["29"] = "\"front\",color_set5"
    cmd["30"] = "\"front\",color_set6"

    if nmb <= 6 then
        rs.setBundledOutput(cmd[nmb])
    elseif nmb >= 7 and nmb <= 12 then
        rs.setBundledOutput(cmd[6])
        rs.setBundledOutput(cmd[nmb])
    elseif nmb >= 13 and nmb <= 18 then
        rs.setBundledOutput(cmd[6])
        rs.setBundledOutput(cmd[12])
        rs.setBundledOutput(cmd[nmb])
    elseif nmb >= 19 and nmb <= 24 then
        rs.setBundledOutput(cmd[6])
        rs.setBundledOutput(cmd[12])
        rs.setBundledOutput(cmd[18])
        rs.setBundledOutput(cmd[nmb])
    elseif nmb >= 25 and nmb <= 30 then
        rs.setBundledOutput(cmd[6])
        rs.setBundledOutput(cmd[12])
        rs.setBundledOutput(cmd[18])
        rs.setBundledOutput(cmd[24])
        rs.setBundledOutput(cmd[nmb])
    end
end