mod_coronium.lua:587: in function 'onResponse' error

Hey! I am pulling my hair out over this one bug, so I hope someone out there can PLEASE help me! 

Here is the situation:

I start off on scene1; which consists of a slide in panel of menu items (Register , sign in, etc). Here is a snippet of my code for this part:

function registerText( item, text, x, y, size, listener )

  options = 

  {

  --parent = textGroup,

  text = text,     

  x = 100,

  y = 200,

  width = 228,     --required for multi-line and alignment

  font = “WorkSans-Medium”,   

  fontSize = 14,

  align = “left”  --new alignment parameter

}

  – body

  panel.item = display.newText( options )

  panel.item:setFillColor( 0,0,0 )

  panel:insert( panel.item )   – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR

  panel.item.x = display.screenOriginX - x

  panel.item.y = display.screenOriginY - y 

  panel.item:addEventListener( “touch”, listener)

end

When I navigate to a different scene, and then go back to scene1. Sometimes (not every time) when I return back to scene1, a menu item (“New user? register here”) pops up randomly on the screen, accompanied by this error in the console:

stores.lua:2265: attempt to call method ‘insert’ (a nil value)

                    stack traceback:

                    [C]: in function ‘insert’

                    stores.lua:2265: in function ‘registerText’

                    stores.lua:2467: in function ‘_callback’

                    mod_coronium.lua:587: in function ‘onResponse’

                    mod_coronium.lua:460: in function <mod_coronium.lua:460>

I have a feeling it is due to poor internet connectivity, and if so, how would I go about preventing this happening? If it’s not due to poor internet connectivity, then what could be the cause?

Also, line 2265 refers to  panel:insert( panel.item ) which is triggering the insert nil error.

Please please please can someone guide me in the right direction.

Thanks!

Hey! I am pulling my hair out over this one bug, so I hope someone out there can PLEASE help me! 

Here is the situation:

I start off on scene1; which consists of a slide in panel of menu items (Register , sign in, etc). Here is a snippet of my code for this part:

function registerText( item, text, x, y, size, listener )

  options = 

  {

  --parent = textGroup,

  text = text,     

  x = 100,

  y = 200,

  width = 228,     --required for multi-line and alignment

  font = “WorkSans-Medium”,   

  fontSize = 14,

  align = “left”  --new alignment parameter

}

  – body

  panel.item = display.newText( options )

  panel.item:setFillColor( 0,0,0 )

  panel:insert( panel.item )   – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR

  panel.item.x = display.screenOriginX - x

  panel.item.y = display.screenOriginY - y 

  panel.item:addEventListener( “touch”, listener)

end

When I navigate to a different scene, and then go back to scene1. Sometimes (not every time) when I return back to scene1, a menu item (“New user? register here”) pops up randomly on the screen, accompanied by this error in the console:

stores.lua:2265: attempt to call method ‘insert’ (a nil value)

                    stack traceback:

                    [C]: in function ‘insert’

                    stores.lua:2265: in function ‘registerText’

                    stores.lua:2467: in function ‘_callback’

                    mod_coronium.lua:587: in function ‘onResponse’

                    mod_coronium.lua:460: in function <mod_coronium.lua:460>

I have a feeling it is due to poor internet connectivity, and if so, how would I go about preventing this happening? If it’s not due to poor internet connectivity, then what could be the cause?

Also, line 2265 refers to  panel:insert( panel.item ) which is triggering the insert nil error.

Please please please can someone guide me in the right direction.

Thanks!

Typically that kind of error occurs when the group object/scene in question no longer exists. It makes sense that this would occur as a result of you returning to the scene. As for why the function is being called, I’d have to guess that something in your code is triggering a response from the server that later calls your “registerText” function. I’d investigate as to what causes the call to occur, and work your way backwards to see why the call is firing when you return to the scene.

Just eye-ballin’ - but wouldn’t this nil itself out? Putting the panel.item in panel, which is panel.

[lua] panel:insert( panel.item ) – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR[/lua]

Another option, like IKinx mentioned is that you’re losing scope somewhere, so it’s getting re-triggered, but I cant tell that from this snippet.

And lastly, you could try a “tap” event listener. I know on Android specifically I’ve had issues with the “touch” event firing in odd ways.

Hope that helps.

Hey! I am pulling my hair out over this one bug, so I hope someone out there can PLEASE help me! 

Here is the situation:

I start off on scene1; which consists of a slide in panel of menu items (Register , sign in, etc). Here is a snippet of my code for this part:

function registerText( item, text, x, y, size, listener )

  options = 

  {

  --parent = textGroup,

  text = text,     

  x = 100,

  y = 200,

  width = 228,     --required for multi-line and alignment

  font = “WorkSans-Medium”,   

  fontSize = 14,

  align = “left”  --new alignment parameter

}

  – body

  panel.item = display.newText( options )

  panel.item:setFillColor( 0,0,0 )

  panel:insert( panel.item )   – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR

  panel.item.x = display.screenOriginX - x

  panel.item.y = display.screenOriginY - y 

  panel.item:addEventListener( “touch”, listener)

end

When I navigate to a different scene, and then go back to scene1. Sometimes (not every time) when I return back to scene1, a menu item (“New user? register here”) pops up randomly on the screen, accompanied by this error in the console:

stores.lua:2265: attempt to call method ‘insert’ (a nil value)

                    stack traceback:

                    [C]: in function ‘insert’

                    stores.lua:2265: in function ‘registerText’

                    stores.lua:2467: in function ‘_callback’

                    mod_coronium.lua:587: in function ‘onResponse’

                    mod_coronium.lua:460: in function <mod_coronium.lua:460>

I have a feeling it is due to poor internet connectivity, and if so, how would I go about preventing this happening? If it’s not due to poor internet connectivity, then what could be the cause?

Also, line 2265 refers to  panel:insert( panel.item ) which is triggering the insert nil error.

Please please please can someone guide me in the right direction.

Thanks!

Typically that kind of error occurs when the group object/scene in question no longer exists. It makes sense that this would occur as a result of you returning to the scene. As for why the function is being called, I’d have to guess that something in your code is triggering a response from the server that later calls your “registerText” function. I’d investigate as to what causes the call to occur, and work your way backwards to see why the call is firing when you return to the scene.

Just eye-ballin’ - but wouldn’t this nil itself out? Putting the panel.item in panel, which is panel.

[lua] panel:insert( panel.item ) – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR[/lua]

Another option, like IKinx mentioned is that you’re losing scope somewhere, so it’s getting re-triggered, but I cant tell that from this snippet.

And lastly, you could try a “tap” event listener. I know on Android specifically I’ve had issues with the “touch” event firing in odd ways.

Hope that helps.