Saturation and Value not setting in a table

Hello. I am trying to make a color palette creator, where it takes a color, shifts it by an amount, and adds it to a table (this table is for the shades ui). For some reason the saturation and value do not work for this.

Code:

local function step(color, hStep, sStep, vStep, alpha, darken)
    if darken == true then
        hStep = hStep * -1
        sStep = sStep * -1
        vStep = vStep * -1
    end
    color.hue = color.hue + hStep
    color.saturation = color.saturation + sStep
    color.value = color.value + vStep
    color.alpha = alpha
    return color
end
-- Dialog creation
local dlg = Dialog{title="Color Palette Creator (HSV)"}
dlg
    :label{id="debug", text="debugger debugger debugger"}
    :separator{text="Paramaters:"}
    :number{id="palSize", label="Size:", text="1", decimals=0, onchange=function()
        -- Change the max size of the color slider
        dlg:modify{id="palIndex", max=dlg.data.palSize}
    end}
    :slider{id="palIndex", label="Color index:", min=1, max=1}
    :color{id="palColor", label="Base color:", color=app.fgColor}
    :number{id="palStepH", label="Hue step:", text="5", decimals=0}
    :number{id="palStepS", label="Saturation step:", text="-10", decimals=0}
    :number{id="palStepV", label="Value step:", text="10", decimals=0}
    :check{ id="palOverflowH", label="Overflow:", text="Hue", selected=true}
    :check{ id="palOverflowS", text="Saturation", selected=true}
    :check{ id="palOverflowV", text="Value", selected=true}
    :number{id="palAlpha", label="Alpha:", text="255", decimals=0}

    :separator{text="Palette:"}
    :shades{id="palShades", mode="pick", colors={}}
    :button{id="palCreate", text="Create", onclick=function()
        -- Calculate the palette and update
        local index = dlg.data.palIndex
        local size = dlg.data.palSize
        local baseColor = dlg.data.palColor
        local stepH = dlg.data.palStepH
        local stepS = dlg.data.palStepS
        local stepV = dlg.data.palStepV
        local alpha = dlg.data.palAlpha
        local colors = {}
        local color = baseColor
        if size == 1 then 
            dlg:modify{id="palShades", colors={baseColor}}
        else 
            if index == 1 then
                for i = 1, size, 1 do
                    if i == index then 
                        colors[index] = baseColor
                    end
                    color = step(color, stepH, stepS, stepV, alpha, false)
                    colors[i] = color
                end
            elseif index == size then
                --Ignore this
            else 
                --Ignore this
            end
            dlg:modify{id="palShades", colors=colors}
        end
    end}

    :separator{text="Export:"}
    :radio{ id="palExportOptions", label="", text="Add to palette", selected=true}
    :radio{text="Replace palette"}
    :radio{text="As a .png"}
    :button{id="palExport", text="Export"}
    :separator()
    :label{text="Please read the info.html file for usage instructions!"}
    :show{wait=false}