Macro referencing variable and then updating that variable

Can someone tell me why my “adjust” parameters are not working? I know jinja has some weirdness with how macros are evaluated in full before execution but I can’t figure out what the exact problem is:

[gcode_macro set_separation]
gcode: 
    {% set svv = printer.save_variables.variables %}

    {% set oldX = svv.xoffset|float %}
    {% set oldY = svv.yoffset|float %}
    {% set oldZ = svv.zoffset|float %}

    {% if params.X is defined %}
        SAVE_VARIABLE VARIABLE=xoffset VALUE={ params.X|float }
    {% endif %}

    {% if params.Y is defined %}
        SAVE_VARIABLE VARIABLE=yoffset VALUE={ params.Y|float }
    {% endif %}

    {% if params.Z is defined %}
        SAVE_VARIABLE VARIABLE=zoffset VALUE={ params.Z|float }
    {% endif %}

    {% if params.X_adjust is defined %}
        {% set newX = params.X_adjust|float + oldX %}
        SAVE_VARIABLE VARIABLE=xoffset VALUE={ newX|float }
    {% endif %}

    {% if params.Y_adjust is defined %}
        {% set newY = params.Y_adjust|float + oldY %}
        SAVE_VARIABLE VARIABLE=yoffset VALUE={ newY|float }
    {% endif %}

    {% if params.Z_adjust is defined %}
        {% set newZ = params.Z_adjust|float + oldZ %}
        SAVE_VARIABLE VARIABLE=yoffset VALUE={ newZ|float }
    {% endif %}

From my understanding you have to always use upper-case for params.*, ie params.Y_ADJUST, not params.Y_adjust, etc.

From the manual: “Note that parameter names are always in upper-case when evaluated in the macro and are always passed as strings.”

You’re awesome! That worked!