# Help with overlays.create function please

**URL:** <https://forum.electra.one/t/help-with-overlays-create-function-please/3357>\
**Category:** General discussion\
**Created:** [November 7, 2024, 2:35pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357 "2024-11-07T14:35:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiwigrass](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/kiwigrass/32/4983_2.png) [@kiwigrass](https://forum.electra.one/u/kiwigrass)\
**Post date:** [November 7, 2024, 2:35pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357/1 "2024-11-07T14:35:39Z")

</div>

Hi. I have 3 fader controls in a preset that have a dual function depending on the value of a particular list control. Specifically, I need to change the range of the 3 faders and also display a different set of labels. I have the setRange part is working nicely. But can’t get the alternative labels to display. I thought this would work, and the code runs without error, but the alternative labels do not display. Here is my code. I wonder if anyone can see what I am doing wrong. I’m thinking perhaps the pot ref# is not the overlay Id as I am assuming.  
Thanks

```auto
function showNotes() -- Range and Overlay for the Delay and LFO4 fader's note duration options when midi synced
    local syncMode = parameterMap.get(deviceId,PT_NRPN,764) -- Midi sync mode
    local control1 = controls.get (110) -- Delay1 level fader
    local ctrlValue1 = control1:getValue ("value")
    local control2 = controls.get (114) -- Delay2 level fader
    local ctrlValue2 = control2:getValue ("value")
    local control3 = controls.get (74) -- LFO4 frequency fader
    local ctrlValue3 = control3:getValue ("value")
    -- a list of labels for the 10 note duration options when Delay1 or Delay 1+2 are midi synced
    local NoteDurationList1 = {
     { value = 0, label = "1/16D" }, { value = 1, label = "1/8D" }, { value = 2, label = "1/4D" },
     { value = 3, label = "1/16T" }, { value = 4, label = "1/8T" }, { value = 5, label = "1/4T" },
     { value = 6, label = "1/16" }, { value = 7, label = "1/8" }, { value = 8, label = "1/4" }, { value = 9, label = "1/2" }
     }
     -- a list of labels for the 12 note duration options when LFO4 is midi synced
     local NoteDurationList2 = {
     { value = 1, label = "1/1" }, { value = 2, label = "1/2" }, { value = 3, label = "1/4" },
     { value = 4, label = "1/8" }, { value = 5, label = "1/16" }, { value = 6, label = "1/32" },
     { value = 7, label = "1/4T" }, { value = 8, label = "1/8T" }, { value = 9, label = "1/16T" },
     { value = 10, label = "1/4D" }, { value = 11, label = "1/8D" }, { value = 12, label = "1/16D" },
     }
    if syncMode == (2 or 6) then -- midi synced Delay1
      ctrlValue1:setRange (0, 9,0, true) 
      overlays.create(110, NoteDurationList1)
    elseif syncMode == (3 or 7) then -- midi synced Delay1+2
      ctrlValue1:setRange (0, 9,0, true)
      ctrlValue2:setRange (0, 9,0, true)
      overlays.create(110, NoteDurationList1)
      overlays.create(114, NoteDurationList1)
    elseif syncMode == (1 or 5) then -- midi synced LFO4
      ctrlValue3:setRange (1, 12,1, true)
      overlays.create(74, NoteDurationList2)
    else -- not midi synced
      ctrlValue1:setRange (0, 127,0, true) 
      ctrlValue2:setRange (0, 127,0, true)
      ctrlValue3:setRange (1, 127,1, true) 
    end
  end

```

---

<div class="post-metadata">

**Author:** ![oldgearguy](https://avatars.discourse-cdn.com/v4/letter/o/f4b2a3/32.png) [@oldgearguy](https://forum.electra.one/u/oldgearguy)\
**Post date:** [November 7, 2024, 2:50pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357/2 "2024-11-07T14:50:33Z")

</div>

I’m not sure the syntax:

```auto
if syncMode == (2 or 6) then

```

is doing what you think. Try:

```auto
if (syncMode == 2) or (syncMode == 6) then

```

---

<div class="post-metadata">

**Author:** ![kiwigrass](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/kiwigrass/32/4983_2.png) [@kiwigrass](https://forum.electra.one/u/kiwigrass)\
**Post date:** [November 7, 2024, 2:58pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357/3 "2024-11-07T14:58:35Z")

</div>

Thanks. I obviously hadn’t tested all the values of syncMode 🙂 . I made those changes. Nonetheless, while the ranges and labels change as expected (eg., 0-127 becomes 0-9) from teh setRange command. The labels do not change from the next overlays.create command. So I must have that command setup incorrectly.

---

<div class="post-metadata">

**Author:** ![oldgearguy](https://avatars.discourse-cdn.com/v4/letter/o/f4b2a3/32.png) [@oldgearguy](https://forum.electra.one/u/oldgearguy)\
**Post date:** [November 7, 2024, 3:24pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357/4 "2024-11-07T15:24:49Z")

</div>

yes - you’re missing the part about setting the overlayId with a value object.

Take a look in the on-line docs in the Preset Lua Extension section under value.

Since you have the control object (control1, control2, etc) you can use something like

value1 = control1:getValue(“value”)  
and then  
value1:setOverlayId(110) (or whatever).

Again - check the docs and example and give it a try

---

<div class="post-metadata">

**Author:** ![kiwigrass](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/kiwigrass/32/4983_2.png) [@kiwigrass](https://forum.electra.one/u/kiwigrass)\
**Post date:** [November 7, 2024, 5:25pm UTC](https://forum.electra.one/t/help-with-overlays-create-function-please/3357/5 "2024-11-07T17:25:09Z")

</div>

Ah. I see. Thanks! This code seems to work as expected:

```auto
    function showNotes() -- Range and overlay when midi synced
    local syncMode = parameterMap.get(deviceId,PT_NRPN,764) -- Midi sync mode
    local control1 = controls.get (110) -- Delay1 level fader control
    local control2 = controls.get (114) -- Delay2 level fader
    local control3 = controls.get (74) -- LFO4 frequency fader
    local ctrlValue1 = control1:getValue ("value")  
    local ctrlValue2 = control2:getValue ("value")
    local ctrlValue3 = control3:getValue ("value")
    -- labels for the 11 note duration options when Delay1 or Delay 1+2 are midi synced
    local noteList1 = {
     { value = 0, label = "1/16D" }, { value = 1, label = "1/8D" }, { value = 2, label = "1/4D" },
     { value = 3, label = "1/16T" }, { value = 4, label = "1/8T" }, { value = 5, label = "1/4T" },
     { value = 6, label = "1/16" }, { value = 7, label = "1/8" }, { value = 8, label = "1/4" }, 
     { value = 9, label = "1/2" }, { value = 10, label = "1/1" } 
     }
     -- labels for the 12 note duration options when LFO4 is midi synced
    local noteList2 = {
     { value = 1, label = "1/1" }, { value = 2, label = "1/2" }, { value = 3, label = "1/4" },
     { value = 4, label = "1/8" }, { value = 5, label = "1/16" }, { value = 6, label = "1/32" },
     { value = 7, label = "1/4T" }, { value = 8, label = "1/8T" }, { value = 9, label = "1/16T" },
     { value = 10, label = "1/4D" }, { value = 11, label = "1/8D" }, {value = 12, label = "1/16D" }
     }
     overlays.create(1000, noteList1)
     overlays.create(1001, noteList2)
    if (syncMode == 2) or (syncMode == 6) then -- midi synced Delay1
      ctrlValue1:setRange (0, 10,0, true)
      ctrlValue1:setOverlayId(1000)
    elseif (syncMode == 3) or (syncMode == 7) then -- midi synced Delay1+2
      ctrlValue1:setRange (0, 10,0, true)
      ctrlValue2:setRange (0, 10,0, true)
      ctrlValue1:setOverlayId(1000)
      ctrlValue2:setOverlayId(1000)
    elseif (syncMode == 1) or (syncMode == 5) then -- midi synced LFO4
      ctrlValue3:setRange (1, 12,1, true)
      ctrlValue3:setOverlayId(1001)
    else      
      ctrlValue1:setRange (0, 127,0, true) -- reset range to default
      ctrlValue2:setRange (0, 127,0, true)
      ctrlValue3:setRange (1, 127,1, true) 
      ctrlValue1:setOverlayId(0) -- reset overlays to default
      ctrlValue2:setOverlayId(0)
      ctrlValue3:setOverlayId(0)
    end
  end

```
