@DanH Actually this is precisely for that use case of having a fixed amount of automation slots and then reassigning them dynamically.
The documentation of the UserPresetHandler class has some information on how to use it, but here's one example:
const var uph = Engine.createUserPresetHandler();
// We need to implement our own preset data model when we start using
// custom automation slots (because then the connection between UI element and its value is
// not consistent anymore)
function onPresetLoad(obj) {}
function onPresetSave() { return {}; }
uph.setUseCustomUserPresetModel(onPresetLoad, onPresetSave, false);
// We'll define the automation model to send their values to the global cable by default
const var data = [{
"ID": "Slot 1",
"connections": [
{
"cableId": "Slot 1"
}]
}];
uph.setCustomAutomation(data);
// We can also attach callbacks directly to automation events
inline function onAutomation(index, value)
{
Console.print(trace({"index": index, "value": value}));
}
uph.attachAutomationCallback("Slot 1", onAutomation, true);
However it's a fairly advanced concept as it requires you to dissolve the connection between UI elements and their persistent value and implement a custom user preset model so it might be overkill for that simple use case.