"Inspect" an event-table with print?

I want to sent information about an event to the console via print(i), but with no luck. The event is called with

[lua]Runtime:addEventListener( “collision”, onCollision )[/lua]

The function:

[lua]local function onCollision( event )
if ( event.phase == “began” ) then

print(“began”)
print("event.object1: “…event.object1)
–for i,v in ipairs(event) do print(”**: "…i,v) end
–print("event.object1: "…tostring(event.object1))
–print("event.object1._class “…event.object1._class[0])
–for i=0, #event.object1.getmetatable do print(”**: "…i, event[i].object1.getmetatable) end

elseif ( event.phase == “ended” ) then

–print( "ended: " … event.object1 … " & " … event.object2 )
print(“ended”)

end
end[/lua]

As you can see, I tried several version with print (the one commented out), but they all do not get the expected result. Even the ipairs(event) are not called and other things I tried just gave me the keys of the metatables. Is there a way, to “inspect” everything, that is insight the event-table? [import]uid: 75471 topic_id: 12310 reply_id: 312310[/import]

Ok, got more insight.

First I learned about some lua-specifics in the #corona IRC_channel:


If you want to examine the keys of a table, the most thorough way to do it is with a “for k, v in pairs(t) do” loop. That will tell you all keys set on the table itself, and ignore those that are returned only from its metatable. Also, the … operator typically works only on strings and numbers. It applies to other values only if a __concat metamethod has been defined for the object. However, print takes multiple arguments, so you may find it easier to say things like [[print("event.object1: ", event.object1)]]

That print-thing then solved the issue:
[lua]local function onCollision( event )
if ( event.phase == “began” ) then

print(“began”)
for i,v in pairs(event.object1) do print("**: ",i,v) end
print("event.object1: ", event.object1)

elseif ( event.phase == “ended” ) then
print(“ended”)
end
end[/lua]

PS: At the collision-detection stuff, that I wanted to achieve, I got also great insights in the CollisionDetection example, that comes with Corona. [import]uid: 75471 topic_id: 12310 reply_id: 44825[/import]