Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Proxy expected, got nil
Started by TheJoshua974 Nov 11 2017 08:36 AM

4 replies to this topic
proxy #-1 runtime error synthax error nil

Best Answer TheJoshua974 , 11 November 2017 - 11:38 AM

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

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

TheJoshua974

[GLOBAL: userInfoPane.html]
TheJoshua974
  • Observer

  • 7 posts
  • Corona SDK

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)

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,895 posts
  • Enterprise

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



[TOPIC: post.html]
#3

TheJoshua974

[GLOBAL: userInfoPane.html]
TheJoshua974
  • Observer

  • 7 posts
  • Corona SDK

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  



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,895 posts
  • Enterprise

Is the pipe being displayed? 

 

Rob



[TOPIC: post.html]
#5

TheJoshua974

[GLOBAL: userInfoPane.html]
TheJoshua974
  • Observer

  • 7 posts
  • Corona SDK

  Best Answer

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




[topic_controls]
[/topic_controls]