lua-users home
lua-l archive

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


=== FAQ ===

ted wrote:
I would like to have a class data member that is a pointer to a lua function
(or table element).

How do I do this?

Hi ted,

Try luaL_ref and lua_rawgeti. Here is an example: http://lua-users.org/lists/lua-l/2003-07/msg00082.html

Further info:
http://lua-users.org/lists/lua-l/2003-06/msg00297.html

The following excerpt is from: http://lua-users.org/lists/lua-l/2003-07/msg00096.html

- Peter

Rici wrote:
There is no real need to use the registry; if you are embedding Lua in
a main program, you can simply use the first few stack slots to store
whatever you like. Lua scripts cannot see these stack slots, so they
are completely safe. However, your C callbacks won't be able to see
them either, so if you are using C callbacks, you either have to use
the registry or you need to associate the script's package table
(assuming you have built one LTN-11 style) or environment table
(if you setfenv'd) with an upvalue in your C callbacks --
this is my preferred solution, and it is very little more
work than the registry solution. It works very nicely for
configuration tables, too.