(SOLVED) Pass slider value into a function

Hi guys, I’ve inserted a slider and I want to pass its current value inside a function in the same scene.

The code I used to make the slider is:

local function sliderListener( event ) local value = event.value end local slider = widget.newSlider { top = \_H/2+90, left = \_W/2-100, width = 200, value = 70, listener = sliderListener }

while the function where I wanna pass “value” variable in is:

function decreaseRect() if(v \> - value) then rect.y = rect.y - 10 end end

How would I be able to fix this issue? 

Thanks! :slight_smile:

function decreaseRect( value )     if(v \> - value) then         rect.y = rect.y - 10     end end   local function sliderListener( event )      local value = event.value      decreaseRect(value) end local slider = widget.newSlider {     top = \_H/2+90,     left = \_W/2-100,     width = 200,     value = 70,     listener = sliderListener }

Something like that.  I don’t know what v is and why you’re comparing it negative value.

Rob

Thank you so much it finally works!

function decreaseRect( value )     if(v \> - value) then         rect.y = rect.y - 10     end end   local function sliderListener( event )      local value = event.value      decreaseRect(value) end local slider = widget.newSlider {     top = \_H/2+90,     left = \_W/2-100,     width = 200,     value = 70,     listener = sliderListener }

Something like that.  I don’t know what v is and why you’re comparing it negative value.

Rob

Thank you so much it finally works!