Layer select or Sample select??

If your scripting is done on the UI side, or you use UI variables, these get initialised whenever a new preset is loaded.

You might have to do some scripting in a script module where parameter values are saved with the presets.
The UI does not save parameters, it retrieves it from the script module or engine parameters.