Matrix VAR not updating from Custom Module

Hi,

I'm having a lot of trouble with trying to set up this dynamic matrix. If my approach is wrong feel free to correct me.

I'm trying to set up a matrix of dynamic faders that could be read from my custom module. I want to read data from a DAW and create some touchscreen matrix faders. I want to use a matrix so I can dynamically set the number of faders to correspond to the number of faders shown in the DAW in realtime (adding/subtracting).

I've learned now we can't make use of OSC listeners within the matrix props. However, I was thinking from reading previous posts on the forum that we could use local variables.

I've got a cloned fader matrix with the props listed below.

JS{
    var props = {};
    var labels = ["O FX 1", "O FX 2", "A Level", "B Level", "Low Cut", "Res", "Pan", "Level"];
    var colors = ["orange", "orange", "pink", "pink", "aqua", "aqua", "grey", "red"];
    
    // Ensure widgetId is correct
    props.widgetId = "cntn_CLONE";

    // Define nested properties
    props.props = {
        variables: {
            text: VAR{faderLabel} || "NA_#{$}",
            n: $ + 1,
            def: $ * 2 + 50,
            color: colors[$],
            out: [1, 50 + $],
            ctrl: [`ctrl ${50 + $}`],
        },
    };

    return props;
}

Is it not possible to set the VAR{faderLabel value from the custom module? I tried the following below in my custom module.

receive("/SCRIPT", `setVar("text_fader_1", "faderLabel", "${myValueFromCustomModuleHere}")`)

Strange enough, this works if I call the VAR from within OSC from another source using,

console.log("fader 1 label: " + getVar("text_fader_1","faderLabel"))


However, none of the fader labels actually get updated. Is this a bug, or my approach is wrong?

text: VAR{faderLabel} || "NA_#{$}",

This VAR will be interpreted by the matrix itself and not by its children individually, unless you write "VAR_{faderLabel}"

Also "NA_#{$}" should be

"NA_" + $
// or
`NA_${$}`

because it's already in a JS{} block.

Hi Jean,

Thank you for the reply! I've updated my props per your corrects, however I'm still not able to update and reflect the changes within the matrix.

JS{
    var props = {};
    var labels = ["O FX 1", "O FX 2", "A Level", "B Level", "Low Cut", "Res", "Pan", "Level"];
    var colors = ["orange", "orange", "pink", "pink", "aqua", "aqua", "grey", "red"];
    
    // Ensure widgetId is correct
    props.widgetId = "cntn_CLONE";

    // Define nested properties
    props.props = {
        variables: {
            text: `VAR_{faderLabel, NA_${$}}`,
            n: $ + 1,
            def: $ * 2 + 50,
            color: colors[$],
            out: [1, 50 + $],
            ctrl: [`ctrl ${50 + $}`],
        },
    };

    return props;
}

Using this from my custom Module.

receive("/SCRIPT", `setVar("text_fader_1", "faderLabel", "${mixerChannels[0].name}")`)

I've ripped my example out of tempalte in case it helps. Just matrix and button that will print the var of the text_fader_1 if there is one.

matrixFadersExamplev1_DMD.json (12.7 KB)

Ok I get it now, the VARiable is held by the container and not by the text widget in it, you'll need to assign a unique id to the cloned container

props.id = 'ctn_' + $

then you'll be able to set its VARiable

 setVar('ctn_1', 'faderLabel', 'yay !')
1 Like

Ah, thank you Jean! That worked perfectly!

Cheers!