Parameters passed to registered LUA item use functions

So, been working with callbacks on new item use functions and they work great. However, I was wondering if, or how, can we access the parameters passed to those callbacks.

Looking at the C++ code, I see that many items in iuse.cpp has the first two parameters of player *p, item *it.
So the question is, what is passed back to the LUA side. I was able to see that at least the first parameter is LUA userdata, so something is being passed. Since these functions are wrapped and exported out, so they have the same parameters?

If so, how would I address it in LUA? For example, if I have registered the following and trying to print out the name: (which is incorrect in it’s reference, I’ve just tried umpteen different ways):

[code]function test(playref,item)
game.add_msg(tostring(item:display_name()))
end

game.register_iuse(“TESTCODE1”, test)
[/code]

I want to see if there is a way to access any of the fields or functions defined in the class definitions file. Since I’m pretty new to LUA, I am wondering if I am missing the correct syntax to reference the data passed in. This is mainly because I have a whole set of items that only differ with a number in their name. Instead of writing a matching set of handler functions, I would like to have a single function accept the info, parse the item name and then call a different function depending on that name. Should work, I just need to figure out how the data is packed in there.

src/catalua.cpp has the invocation function, docs/sample_mods/manhack has an example.

The callback doesn’t supply the player pointer for some reason, but 3 other values are supplied.

That works, thanks a ton. I could have sworn I tried to bring that in and reference it just like the manhack sample.

Thanks again, Coolthulhu!