Attempt to compare boolean with number

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?

Lua does not allow composite comparisons:

0\<= event.value \<= 20

Sorry, but you’ll need to split this into two separate comparisons.

Sorry, but I don’t understand what that means. What are composite comparisons and how do I split this into two separate comparisons?

if ( 0\<= event.value ) then if ( event.value \<= 20) then ... end end

Thanks! I added that and it worked.

Lua does not allow composite comparisons:

0\<= event.value \<= 20

Sorry, but you’ll need to split this into two separate comparisons.

Sorry, but I don’t understand what that means. What are composite comparisons and how do I split this into two separate comparisons?

if ( 0\<= event.value ) then if ( event.value \<= 20) then ... end end

Thanks! I added that and it worked.