[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: So close! Now: userdata mt help!
- From: Peter Shook <pshook@...>
- Date: Wed, 30 Jul 2003 16:16:51 -0400
Ando Sonenblick wrote:
So that I can then call:
foo:DoSomething(100)
First, is this possible to do with a userdata value type?
Yes, so long as you use full userdata created by lua_newuserdata. Just
create a userdata the size of your pointer and put the pointer inside
the userdata.
The light userdata cannot have a metatable, so it cannot have an index
event.
There are examples on the wiki that use these functions from the auxlib:
LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname);
LUALIB_API void luaL_getmetatable (lua_State *L, const char *tname);
LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname);
Cheers,
- Peter