[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Direct Memory Access to Lua variables?
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Thu, 23 Jul 2009 14:43:44 +0200
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.