• Lua metatables to userdata (Vector, Angle, etc)
    1 replies, posted
Someone contacted me the other day asking if it was possible to create a Vector metatable in Lua and have the engine interpret it as Source's Vector struct. I've been trying to get the engine to recognise the metatable as userdata, but with no success. Out of curiosity, is this possible?
[QUOTE=code_gs;50616682]Someone contacted me the other day asking if it was possible to create a Vector metatable in Lua and have the engine interpret it as Source's Vector struct. I've been trying to get the engine to recognise the metatable as userdata, but with no success. Out of curiosity, is this possible?[/QUOTE] No. This is what goes on when accessing userdata from C: [code] LUA->CheckType(1, Type::VECTOR); UserData* ud = (UserData*)LUA->GetUserdata(1); Vector* myvector = (Vector*)ud->data; [/code] Not only will Lua tables never pass the type check, they will also never return anything but NULL if you tried to read them as userdata.
Sorry, you need to Log In to post a reply to this thread.