It’s not in a FluidNC release yet, but basic support for gcode parameters and expressions has been added. I’m not quite sure what I would do with it yet but it has some potential.
GCode Parameters and Expression | Wiki.js (fluidnc.com)
It doesn’t sound like loops are feasible but they might add conditional (if) statement support.