Hi,
I’m trying to get a slider to change some text when the user moves the slider around. Here is my code:
local myText = display.newText( sceneGroup, "3", display.contentWidth - 25, display.contentHeight - 400, native.systemFont, 24 ) myText:setFillColor(0,0,0) -- Slider listener local function sliderListener( event ) print( "Slider at " .. event.value .. "%" ) if ( 0\<= event.value \<= 20) then myText.text = "3" elseif ( 21\<= event.value \<= 40) then myText.text = "4" elseif ( 41\<= event.value \<= 60) then myText.text = "5" elseif ( 61\<= event.value \<= 80) then myText.text = "6" elseif ( 81\<= event.value \<= 100) then myText.text = "7" end end -- Create the widget local myTextSlider = widget.newSlider { top = display.contentHeight - 380, --up and down left = display.contentWidth - 320,--side to side width = 285, value = 0, -- Start slider at 0 listener = sliderListener }
So if the slider is in between or equal to 1 and 20, myText.text = “3”. If the slider is in between or equal to 21 and 40, myText.text = “4”. If the slider is in between or equal to 41 and 60, myText.text = “5”, and so on.
However, when I try to move the slider on the simulator, I get an error message:
“attempt to compare boolean with number”
How come this is happening?