Re: Changing Images – what could be wrong in that LUA code

Home Forums General Programming Changing Images – what could be wrong in that LUA code Re: Changing Images – what could be wrong in that LUA code

#4466
Cramp
Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":snd3lps3 wrote:
    All i can say is that i checked it with the latest nightly build and it work for me, so there must be some bug in your code.[/quote:snd3lps3]

    I checked a code again. it works fine. I can see the made changes for that uiFixedImageSlider component on it Properties. But it is not changing on Panel visualy.

    ok, lets do a experiment
    I wanna check with you one thing if you will open my panel that I sent your before (the latest one) and then
    [img:snd3lps3]http://dl.dropbox.com/u/4202790/experiment.png[/img:snd3lps3]
    if you can see on picture 2 buttons – marked as RED is Single Filter and marked as BLUE is MultiFilter
    and one slider (uiFixedImageSlider) marked as YELLOW
    1. select RED button and set the value as shown on picture (DistLP). in theory the YELLOW slider should be shown as on picture – with turned on light. BLUE should be off
    2. now if you selected the RED with different value YELLOW slider should turn its lights off

    I need this because in Ctrlr Revision 1047 (not build) visuals worked fine, and in the latest build (revision 1056) visuals doesn’t work exatly with this type of Slider (uiFixedImageSlider). Visual works with uiImageButtons

    Could you please check it for me? Many thanks

    p.s. I also change my code according to your example.
    [code:snd3lps3]FilterSwitch = function(modulator, newValue)

    — Images ON Status

    MultiFilterTypeOn = "sixfold_selection_filter"
    SingleFilterTypeOn = "sixfold_selection_filter"
    FilterSlopeTypeOn = "led_three_upward2"

    — Images OFF Status

    MultiFilterTypeOff = "sixfold_selection_filteroff"

    SingleFilterTypeOff = "sixfold_selection_filteroff"
    FilterSlopeTypeOff = "led_three_upward_off"

    — When click this know Filter mode changes to Multi

    — filterslope modulator
    filter_slope_mod = panel:getModulatorByName("FilterSlope")

    — Single Filter Type modulator
    single_filter_mod = panel:getModulatorByName("FilterType")

    — Multi Filter Type and Led Modulators
    multi_filter_mod = panel:getModulatorByName("FilterEnvCtrl")

    — Frequency2/Dist Slider modulator
    freq_dist_mod = panel:getModulatorByName("FilterFreq2")

    — This knob on click disables Multi Filter type that is why Filter Slope and Single Filter Type knobs
    — need to be enabled. And MultiFilter knob plus Filter2 need to be disabled. Filter2 runs with CC 114


    — Enabling Dist Slider if DIST LP (58) value is Selected on Filter Type and
    — set MIDI CC 114 to Frequency2/Dist Slider modulator
    — Disable Slope if Single Filter equal BR type

    mod = panel:getModulatorByName("FilterFreq2")
    if mod ~= nil then
    midi = mod:getMidiMessage()
    if midi ~= nil then
    if newValue >58 then
    midi:setPropertyInt ("midiMessageCtrlrNumber", 59)
    else
    midi:setPropertyInt ("midiMessageCtrlrNumber", 114)
    end
    end
    end

    if freq_dist_mod ~= nil and filter_slope_mod ~= nil and single_filter_mod ~= nil and multi_filter_mod ~= nil then

    if newValue == 0 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOn)
    filter_slope_mod:setModulatorValue (2, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-off")
    end
    elseif newValue == 1 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOn)
    filter_slope_mod:setModulatorValue (2, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-off")
    end
    elseif newValue == 2 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOn)
    filter_slope_mod:setModulatorValue (2, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-off")
    end
    elseif newValue == 3 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOff)
    — filter_slope_mode:setModulatorValue (0, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-off")
    end

    elseif newValue == 4 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOn)
    filter_slope_mod:setModulatorValue (2, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-off")
    end
    elseif newValue == 5 then
    comp_freq = freq_dist_mod:getComponent()
    comp_slope = filter_slope_mod:getComponent()
    comp_multi = multi_filter_mod:getComponent()
    comp_single = single_filter_mod:getComponent()
    if comp_freq ~= nil and comp_slope ~= nil and comp_multi ~= nil and comp_single ~= nil then
    comp_slope:setPropertyString ("uiImageButtonResource", FilterSlopeTypeOn)
    filter_slope_mod:setModulatorValue (1, false, true, true)
    comp_single:setPropertyString ("uiImageButtonResource" , SingleFilterTypeOn)
    comp_multi:setPropertyString ("uiImageButtonResource" , MultiFilterTypeOff)
    comp_freq:setPropertyString ("uiImageSliderResource", "filter-on")
    end
    end

    end

    end[/code:snd3lps3]

    Ctrlr