lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 2-Feb-07, at 12:20 PM, Zé Pedro wrote:

Sorry I've sent the message unfinished...

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.

At the risk of being obvious:

int my_newmetatable (lua_State *L, const char *tname) {
  int rc = luaL_newmetatable(L, tname);
  if (rc) {
    lua_pushstring(L, tname);
    lua_setfield(L, -2, "__typename");
  }
  return rc;
}