I am trying to spawn a new display.newRect if to old one is < 100 but I’m getting a ‘Attempt to compare nil with number’
function hollSpawne(i) if (i).x \< 100 then hollspawn() end end HollControll = timer.performWithDelay( 1400 , hollSpawne, 0 )
I cant see the error, could someone please explain how to fix this ?
Fullcode :
function pluspoint(i) score = score + 1 display.remove(i) end screenGroup = self.view holl = {} hollSpawn = function() i = display.newRect( 0, 0, math.random(10, 500), 53 ) i.x = display.contentWidth + i.contentWidth + 10 i.y = display.contentHeight - 53/2 i:setFillColor( 1, 0, 0 ) i.name = "hollgameover" physics.addBody(i, "static", {density=.1, bounce=0.5, friction=.2,filter=playerCollisionFilter } ) trans55 = transition.to(i,{time=2000, x=display.contentWidth - display.contentWidth - i.contentWidth/2 - 20, onComplete=pluspoint, transition=easing.OutExpo } ) holl[#holl+1] = i screenGroup:insert(i) end timereholl = timer.performWithDelay( 100 , hollSpawn, 1 ) function hollSpawne(i) if (i).x \< 100 then hollspawn() end end HollControll = timer.performWithDelay( 1400 , hollSpawne, 0 )