how to map LUA Gui slider so that it's value can be written "w

Hi, I’m trying to make a slider write to a specific value. like note_column.delay_value or something.

I’m trying to do it like this:

local effect_slider = vb:column {vb:minislider{id="effectslider", width=30,height=127}}

function effectslide()
print (vb.views["effectslider"].value)
renoise.song().selected_track.delay_column_visible=true
renoise.song().selected_track.delay_column_value = vb.views["effectslider"].value
end

I’m not sure if this is the way, I thought that it would be possible to just define an id and thus read it. but I keep getting errors like

***./CheatSheet.lua:263: assign to undeclared variable 'effectslide'
*** stack traceback:
*** [C]: in function '_error'
*** [string "local mt = getmetatable(_G)..."]:17: in function <[string "local mt = getmetatable(_G)..."]:10>
***./CheatSheet.lua:263: in function 'CheatSheet'
***./CheatSheet.lua:288: in function <./CheatSheet.lua:288>

this really weirds me out.

--delay slider value
function my_dly_slider( value )
  local song = renoise.song()
  local snci = song.selected_note_column_index
  --shield inside any note column with a condition
  if ( snci > 0 ) then
    local nc = song.selected_line:note_column( snci )
    nc.delay_value = value
  end
end

--define the slider, or minislider to viewbuilder
MY_DLY_SLIDER = vb:slider {
  id = "DLY_SLIDER",
  --midi_mapping = MIDI_IN.DLY_SLIDER,
  width = 22, --width = 400
  height = 400, --height = 22
  min = 0,
  max = 255,
  active = true,
  notifier = function(value) my_dly_slider(value) end,
  tooltip = "My tooltip delay slider"
}

You can use a similar code for the other parameters: note, instrument, volume, panning …Remember that “value” is a variable passed by the slider in the superior function.

function my_dly_slider( value )
local song = renoise.song()
local snci = song.selected_note_column_index
--shield inside any note column with a condition
if ( snci > 0 ) then
local nc = song.selected_line:note_column( snci )
nc.delay_value = value
end
end

Just a quick suggestion to simplify this guy, since there’s really no need to check indexes, lines, etc…

function my_dly_slider( value )
  local nc = renoise.song().selected_note_column
  if nc ~= nil then
    nc.delay_value = value
  end
end

Sometimes less is more :slight_smile:

Just a quick suggestion to simplify this guy, since there’s really no need to check indexes, lines, etc…

function my_dly_slider( value )
local nc = renoise.song().selected_note_column
if nc ~= nil then
nc.delay_value = value
end
end

Sometimes less is more :slight_smile:

Wow, perfect!Better to check directly if the object is not null. This will help me improve a few functions that I am using in my tools. Thanks!!!