runtime error

Im having issues when i copy my level file. The second level is crashing and im getting a error I’ve never seen before. Any help would be great. Thank you

Below is the error
Runtime error
…scene1.lua:545: attempt to concatenate field ‘myName’ (a nil value)
stack traceback:
[C]: ?
…scene1.lua:545: in function <542>
?: in function <?:226>
Runtime error
…scene1.lua:576: attempt to concatenate field ‘myName’ (a nil value)
stack traceback:
[C]: ?
…scene1.lua:576: in function <542>
?: in function <?:226>

The below code is from line 542 to 576

[lua]local function onGlobalCollision( event )
if ( event.phase == “began” and gameOverBool==false) then

print( “Global report: " … event.object1.myName … " & " … event.object2.myName … " collision began” )

if (event.object1.myName == “enemy” and event.object2.myName == “monkey”) then
print (“Monkey hit enemy!”)
timer.performWithDelay(100, removeAfterDelay(event.object1) )

elseif (event.object1.myName == “wall” and event.object2.myName == “monkey”) then --Monkey must die!

audio.stop(bgMusic)

physics.setGravity(0,0)
monkey:setLinearVelocity( 0, 0 )

monkey:prepare(“monkeyDie”)
monkey:play()
monkeyMotion.alpha = 0.0

print (“Monkey hit wall!”)

timer.performWithDelay(20, gameOverFunctionStart )

else --Monkey has landed safely
monkey:prepare(“monkeyLand”)
monkey:play()
monkeyMotion.alpha = 0.0
timer.performWithDelay(400, resetMonkeyToIdleStance )
end [import]uid: 80826 topic_id: 30274 reply_id: 330274[/import] 542>542>

In line 4 above, it looks like event.object1.myName (and event.object2.myName?) is nil.

Put a test / print statement above it to check the variables, such as:

if( event.object1.myName == nil ) then
print(" – Drats! event.object1.myName == nil")
end

As to why, beats me, but it looks like it’s crapping out concatenating the strings for the print statement.

When in doubt, always carpet bomb with the print! :slight_smile: [import]uid: 79933 topic_id: 30274 reply_id: 121302[/import]

Your event.object1.myName is nil, and so print fails. Try commas in print instead of concats. [import]uid: 160496 topic_id: 30274 reply_id: 121296[/import]

It works fine with just one level. But when I copy the level file to make more than one level is when it doesn’t work.

@mike I tired that it didn’t work.

@mpappas I’ll tru that when I get home.

This has got me puzzled [import]uid: 80826 topic_id: 30274 reply_id: 121344[/import]

In line 4 above, it looks like event.object1.myName (and event.object2.myName?) is nil.

Put a test / print statement above it to check the variables, such as:

if( event.object1.myName == nil ) then
print(" – Drats! event.object1.myName == nil")
end

As to why, beats me, but it looks like it’s crapping out concatenating the strings for the print statement.

When in doubt, always carpet bomb with the print! :slight_smile: [import]uid: 79933 topic_id: 30274 reply_id: 121302[/import]

Your event.object1.myName is nil, and so print fails. Try commas in print instead of concats. [import]uid: 160496 topic_id: 30274 reply_id: 121296[/import]

It works fine with just one level. But when I copy the level file to make more than one level is when it doesn’t work.

@mike I tired that it didn’t work.

@mpappas I’ll tru that when I get home.

This has got me puzzled [import]uid: 80826 topic_id: 30274 reply_id: 121344[/import]