Sub Layer ModMatrix parameter

Hello,
I am finding some difficult to detect the right script to reach mod matrix parameter if I have different sub layer. I post an example of my actual script (it does not work) and an image of the tree.
I’ve solved (thanks to misohoza) in a previous topic the same issue but in a simple (this.parent:getZone():getModulationMatrixRow():setParameter) tree.

Thanks you!
tree.png

-- set parameter of all zones
function setParameterOfZones(parameterName, value)
	local zones = this.parent:findZones(true)
    for i, zone in pairs(zones) do
		zone:setParameter(parameterName, value)
	end
end

-- reset LFO Rate and Int.1
function onResetDestsLFO1()


newRateLFO1 = 0
newDest1LFO1OSC1 = 0

    setParameterOfZones("LFO 1.Rate", newRateLFO1)

    this.parents:getLayer("Generator 1"):getLayer("OSC"):getZone("OSC Zone"):getModulationMatrixRow(1):setParameter("Destination.Depth", newDest1LFO1OSC1)

end

defineParameter("ResetDestsLFO1", onResetDestsLFO1)

UPDATE
Now it work with the follow script. But I have many zones and many matrix row destinations. It would be great if I can short the script, because with in this way I have to set over 150 script line :open_mouth:

-- Reset LFO1 Dest

zone1 = this.program:findZones(true)[1]

MRow1 = zone1:getModulationMatrixRow(1)


function onResetLFO1Dest1()


newLFO1Dest1 = 0

    MRow1:setParameter("Destination.Depth", newLFO1Dest1)

end

defineParameter("ResetLFO1Dest1", onResetLFO1Dest1)

Hi FedericoS,

You can adapt the setParameterOfZones function to make it work with modulation matrix parameters:

function setModParameterOfZones(rowNumber, parameterName, value)
  local zones = this.parent:findZones(true)
  for i, zone in ipairs(zones) do
    local modRow = zone:getModulationMatrixRow(rowNumber)
    modRow:setParameter(parameterName, value)
  end
end

setModParameterOfZones(1, "Destination.Depth", 25)

You could also combine the two and use it for both regular zone parameters and modulation matrix parameters:

-- last argument is optional
-- only used with modulation matrix parameters

function setParameterOfZones(parameterName, value, rowNumber)
  local zones = this.parent:findZones(true)
  for i, zone in ipairs(zones) do
    if rowNumber and type(rowNumber) == "number" then
      local modRow = zone:getModulationMatrixRow(rowNumber)
      modRow:setParameter(parameterName, value)
    else
      zone:setParameter(parameterName, value)
    end
  end
end

setParameterOfZones("ZoneType", 1)
setParameterOfZones("Destination.Depth", 50, 1)

misohoza, thanks for your usual precious support and help… (Halion is taking me away from real life :nerd: ).
First script is perfect for my need!
Thanks again