Sub Preset switching breaks functionality of script.

I’ve linked together the Bypass of multiple mod matrix rows via script and it works as expected. My script also includes callback so when I switch subpresets it copies/pastes zone settings. This works too. However, on the macro page, the switch I have attached to the script to bypass multiple mod matrix rows no longer works after a sub preset is switched. This doesn’t create any script errors and everything appears healthy, it just no longer functions. You can see in HALion 6 that the Bypass function works and when you change sub presets that the mod matrix was copied correctly but the function no longer works.

I’ve created an exported library capable of demonstrating what I’m experiencing.

Link to library: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

Any help is much appreciated!

Thanks!

Hi rmjmusic,

The fix is quite simple. Just move the bypassLink variable inside the callback function. Otherwise it refers to a zone that was found when the script loads. But the zone changes when you load new layer preset.

--LFO BYPASS LINKS


function onLFOBypassChanged()
  local bypassLink =   this.parent:getLayer():getZone()
  if LFOBYPASSLINK == true then
    bypassLink:getModulationMatrixRow(1):setParameter(655370, false)
    bypassLink:getModulationMatrixRow(2):setParameter(655370, false)
    bypassLink:getModulationMatrixRow(3):setParameter(655370, false)
    bypassLink:getModulationMatrixRow(4):setParameter(655370, false)
  else
    bypassLink:getModulationMatrixRow(1):setParameter(655370, true)
    bypassLink:getModulationMatrixRow(2):setParameter(655370, true)
    bypassLink:getModulationMatrixRow(3):setParameter(655370, true)
    bypassLink:getModulationMatrixRow(4):setParameter(655370, true)
  end
end

defineParameter( "LFOBYPASSLINK", "LFO Bypass Link", true, onLFOBypassChanged)

Big thanks, misohoza! You never fail. It works.
Its nuances like this in the scripting that reveal to me how much I still have to learn. Thank you again!