Debugging for two days now but NO progress

Does this error mean that the SECOND argument to ‘insert’ is nil?

.../Data1/iDev/Corona Projs/TOT/TOTscreenController.lua:184: bad argument #-2 to 'insert' (Proxy expected, got nil)

This is really strange because I can print the object that is the second argument and it shows that the second argument IS NOT nil:

‘buttonsGroup’ was created with display.newGroup()
‘buttonsGroupInd’ holds the integer 1
‘rotatedPiecePanel’ is a table which holds display objects:

local buttonsGroup = display.newGroup()  
local buttonsGroupInd = 1  
local rotatedPiecePanel = {}  
  
local button = display.newImage("TheButton")  
button.id = "But1-1"  
button.rotIndex = 1  
  
rotatedPiecePanel[1] = button  
  
print("Will Install: ".. rotatedPiecePanel[1].id .."; rotInd is ".. rotatedPiecePanel[1].rotIndex)  
buttonsGroup:insert(buttonsGroupInd, rotatedPiecePanel[1])   

The above code outputs this to the console:

Will Install: But1-1; rotInd is 1  
Runtime error  
 .../Data1/iDev/Corona Projs/TOT/TOTscreenController.lua:184: bad argument #-2 to 'insert' (Proxy expected, got nil)  

Another strange thing is that the first time the above code is executed there is no error. The error occurs the second time it is executed. [import]uid: 295 topic_id: 1708 reply_id: 301708[/import]

When you say “second time it is executed”, do you mean you reload? Can you post a complete example in which this happens? [import]uid: 54 topic_id: 1708 reply_id: 4996[/import]

Hello Eric,

Thanks for your time again but I just got it sorted out.

What I was doing wrong was I had a main display group of 4 buttons (display objects). And I had a table of more buttons (display objects) representing rotated versions of each of the 4 main buttons - 19 buttons in all to represent the unrotated state and rotated in 45 degree increment states for each of the 4 main buttons.

Clicking a button would call a function that rotated the buttons. The function would assign / insert (I tried everything) a rotated button from the table to the main display group. I tried removing/not removing the button to be rotated from the main display group before assigning / inserting in the corresponding position the rotated button from the table.

I tried every combination I could think of and kept getting that error the 2nd time through the rotation sequence. I tried using a main button GROUP and a rotated button GROUP. I tried making them both tables. But nothing worked. I could get it so it looked like everything was working, but the 2nd time through would give me that error.

Then I read something in the forum about putting a display object in a table causes the object to lose the properties that make it a display object.

Anyway I solved the problem by making everything display groups: 1 group for the main button display. 4 groups (1 for each of the 4 buttons) to hold the rotated versions of each button. Then I’d only use insert (no remove) to move the corresponding buttons back and forth between the main display group and the corresponding rotated buttons group.

That works like a charm. [import]uid: 295 topic_id: 1708 reply_id: 4997[/import]

Lately, working with moving display objects between groups I get bus errors all the time. Is this normal?

It’s like I’m accessing / overwriting reserved memory directly like is possible in a C or assembly language program.

Damn I wish the debugger worked. It’s becoming a pain moving print statements around, starting up the Corona simulator, navigating to the folder where my code resides…running the code, getting a buss error, then repeating the process over and over.

I also wished the Corona simulator would remember the previous working folder so that when it started up the Open dialog would start in that folder. [import]uid: 295 topic_id: 1708 reply_id: 5011[/import]

tokyodan

can you send me code to see what and why is happening ?

cicaza AT anscamobile.com

c [import]uid: 24 topic_id: 1708 reply_id: 5016[/import]

Carlos. Thanks but I could fix it. But without the debugger working it was a pain to find out what was causing the bus errors.

I’m just more concerned as to why bus errors and crashing out of Simulator was happening. Isn’t Lua/Corona supposed to prevent that because there are no pointers nor ways to access memory directly? [import]uid: 295 topic_id: 1708 reply_id: 5018[/import]

You should never be able to crash the simulator. If you have a reproducible case please send to support@. [import]uid: 54 topic_id: 1708 reply_id: 5020[/import]

I found a reproducible bus error

It happens with Corona2.0-Beta7

It’s in the file TOTkillValueForPositions.lua

the area is question is in function findOverallStrengthForPos(), lines 150 - 161.

I found it by decreasing the ‘pieceTyp’ variable instead of directly assigning a correct value to it.

Run the game in the Corona Terminal.

  1. drag any red button from the bottom bar to the game board.
  2. The Computer will move a blue button from the very right of the bottom bar to the board. There are only 5 of the rightmost button.

Repeat steps 1 & 2 till the computer moves all 5 of the blue right most buttons.
When the blue right most button reaches 0 a bus error will occur.

The sent an email to support@anscamobile.com with the same explanation as above and the project attached.

[import]uid: 295 topic_id: 1708 reply_id: 5111[/import]