lua-users home
lua-l archive

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


2009/7/22 b's spam <spam@inlandstudios.com>:
> I'm writing a C++ wrapper class that allows me to manipulate variables in a
> loaded lua script. It works fine, but is very slow because I'm performing
> these operations many times (in real-time). Is there a way to write directly
> to the memory location without having to search and push the variable onto
> the stack by name?

If you're doing a lot more C access than Lua access, you can store the
variable data in a userdata, that will never be moved (just store its
address in your C code). Then you can use index/newindex metamethods
to read or write that data from Lua.