if condition

hii.,

i write a simple code,and apply if statement but there is problem with the condition part

here is my code:

local ball=display.newImageRect("ball.png",100,100) ball.x=display.contentCenterX ball.y=display.contentCenterY local function ballmove(self,event) self.x=self.x-3; end ball.enterFrame=ballmove Runtime:addEventListener("enterFrame",ball) if (0\<ball.x\<display.contentWidth) then print("chetan") end

and error is: Attempt to compare boolean with number

That’s because you are trying to make a statement that’s not available in Lua. Here is how you code an if statement in Lua -> https://www.lua.org/pil/4.3.1.html

If 0<ball.x then
If ball.x<display.contentWidth then
Print(“Devan”)
end
end

@jaime159castilo

thanks a lot …

That’s because you are trying to make a statement that’s not available in Lua. Here is how you code an if statement in Lua -> https://www.lua.org/pil/4.3.1.html

If 0<ball.x then
If ball.x<display.contentWidth then
Print(“Devan”)
end
end

@jaime159castilo

thanks a lot …