Proxy expected, got nil

Hello, to train myself using Corona I’m making a flappy bird clone,

Everything was fine until I encounters this error:

main.lua:90: bad argument #-1 to ‘addBody’ (Proxy expected, got nil)

I couldn’t find any solution and for fact if I call the function outside the gameLoop, oddly it works anyone got an idea of what I did wrong?

-------------------------------------------------------------------------- local pipefile = -- { -- frames = { -- { -- up -- x = 77, -- y = 10, -- width = 26, -- height = 115 -- }, -- { -- down -- x = 77, -- y = 153, -- PIPES width = 26, -- height = 107 -- }, -- } -- } -- -- local pipesheet = graphics.newImageSheet( "pipes.png", pipefile ) -- -- pipes = { -- ["up"] = display.newImageRect( mainGroup, pipesheet, 1, 40, 200 ), -- ["down"] = display.newImageRect( mainGroup, pipesheet, 2, 40, 200 ) -- } -- -------------------------------------------------------------------------- --function that errors-- local function createPipe(y) local newPipe = pipes.down table.insert( pipesTable, newPipe ) physics.addBody( newPipe, "kinematic", { radius=40, bounce=0.8 } ) --LINE 90 newPipe.myName = "pipe" newPipe.x = display.contentCenterX\*2 newPipe.y = display.contentCenterY\*1.5 + y newPipe:setLinearVelocity( -100, 0 ) newPipe:applyTorque( math.random( 10,10 ) ) end --where it's called-- local function gameLoop() createPipe(math.random(2,4)) for i = #pipesTable, 1, -1 do local thisPipe = pipesTable[i] if thisPipe.x \< 1000 then display.remove( thisPipe ) table.remove( pipesTable, i ) end end end gameLoopTimer = timer.performWithDelay( 500, gameLoop, 0 )

(this is not the entire code but only the part that seems to be important)

Hello and welcome to the forums.

Corona should provide you a console log window that may have more information in it. If you could copy/paste the content from the log window would be very helpful.

Basically, the message is saying that:

local newPipe = pipes.down

pipes.down is nil for some reason.

Rob

It doesnt seem to have a ton of informations but here it is!

17:28:28.819 Copyright (C) 2009-2017 C o r o n a L a b s I n c . 17:28:28.819 Version: 3.0.0 17:28:28.819 Build: 2017.3135 17:28:28.819 Platform: KFJWI / x64 / 10.0 / Intel(R) HD Graphics 530 / 4.4.0 - Build 20.19.15.4364 / 2017.3135 / fr\_FR | FR | fr\_FR | fr 17:28:28.819 Loading project from: C:\Users\joshu\Documents\Corona Projects\Flay ir 17:28:28.819 Project sandbox folder: C:\Users\joshu\AppData\Local\Corona Labs\Corona Simulator\Sandbox\flay ir-58828D347ED73897921DF11666096500\Documents 17:28:30.063 ERROR: Runtime error 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:90: bad argument #-1 to 'addBody' (Proxy expected, got nil) 17:28:30.063 stack traceback: 17:28:30.063 [C]: in function 'addBody' 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:90: in function 'createPipe' 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:115: in function '\_listener' 17:28:30.063 ?: in function '?' 17:28:30.063 ?: in function \<?:190\> 17:28:57.082

Is the pipe being displayed? 

Rob

Yes it was but I found out what caused the error, It was at this line : if thisPipe.x < 1000 then the < was supposed to be a > wish oddly caused this error, sorry if I wasted your time, but thanks!

-TheJoshua974

Hello and welcome to the forums.

Corona should provide you a console log window that may have more information in it. If you could copy/paste the content from the log window would be very helpful.

Basically, the message is saying that:

local newPipe = pipes.down

pipes.down is nil for some reason.

Rob

It doesnt seem to have a ton of informations but here it is!

17:28:28.819 Copyright (C) 2009-2017 C o r o n a L a b s I n c . 17:28:28.819 Version: 3.0.0 17:28:28.819 Build: 2017.3135 17:28:28.819 Platform: KFJWI / x64 / 10.0 / Intel(R) HD Graphics 530 / 4.4.0 - Build 20.19.15.4364 / 2017.3135 / fr\_FR | FR | fr\_FR | fr 17:28:28.819 Loading project from: C:\Users\joshu\Documents\Corona Projects\Flay ir 17:28:28.819 Project sandbox folder: C:\Users\joshu\AppData\Local\Corona Labs\Corona Simulator\Sandbox\flay ir-58828D347ED73897921DF11666096500\Documents 17:28:30.063 ERROR: Runtime error 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:90: bad argument #-1 to 'addBody' (Proxy expected, got nil) 17:28:30.063 stack traceback: 17:28:30.063 [C]: in function 'addBody' 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:90: in function 'createPipe' 17:28:30.063 C:\Users\joshu\Documents\Corona Projects\Flay ir\main.lua:115: in function '\_listener' 17:28:30.063 ?: in function '?' 17:28:30.063 ?: in function \<?:190\> 17:28:57.082

Is the pipe being displayed? 

Rob

Yes it was but I found out what caused the error, It was at this line : if thisPipe.x < 1000 then the < was supposed to be a > wish oddly caused this error, sorry if I wasted your time, but thanks!

-TheJoshua974