[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: noob - How to architect c++ code to use lua as external code
- From: Kevin Martin <kev82@...>
- Date: Mon, 22 Oct 2012 19:08:50 +0100
On 22 Oct 2012, at 18:51, Coda Highland wrote:
> Why use something as clumsy as a UUID for the key when you get a
> unique ID back from luaL_ref?
How can I use luaL_ref? I'm thinking to have a static function such as:
static int foo(lua_State *l) {
lua_pushstring(l, "special key");
lua_gettable(l, LUA_REGISTRYINDEX);
SomeObject *o = lua_touserdata(l, -1);
o->bar();
return 0;
}
foo needs to know at compile time where to look to get the object (as there is no runtime data passed to foo), the returned value from luaL_ref is not known until runtime.
Thanks,
Kev