Hi, I have a method in C++ accessible from Lua that receives an userdata object as a parameter. But it can receive one of several userdata
types.If I could get the string that I used when the metatable was created (luaL_newmetatable(pLuaState, "
Zara.sound");) I could compare it, but I can't find a way to do it.
Consider the following example:
int LObject::setRepresentation(lua_State* pLuaState)
{
try
{
//In here I'm trying to get the field were the userdata type is set (I thought that this could be a way to do it)
cout << "--------------------------------" << endl;
cout << lua_objlen(pLuaState,1) << endl; //It returns 4 so I thought one of the positions would be the type
cout << "-" << endl;
lua_rawgeti(pLuaState,1,1); //in what position is it?
type = lua_tostring(pLuaState,-1);
cout << type << endl;
cout << "--------------------------------" << endl;
Representation* rep = static_cast<ZMaterial*>(luaL_checkudata(pLuaState,3,type)); //Where type can something like Zara.sound, Zara.model, ...
}
}