[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How can I avoid changing the _ENV of a whole file when changing the _ENV of a lua function?
- From: Tom N Harris <telliamed@...>
- Date: Fri, 17 Feb 2012 20:19:52 -0500
On 02/17/2012 03:53 AM, John Tan wrote:
After trying such code I found that if I change the _ENV of a lua
function, it will change the _ENV of whole file.
I wonder if there is any way I can only change the _ENV of a certain
lua function without affecting the other part of the script.
THX in advance.
I believe what you want is lua_upvaluejoin. If you just change the
value, then all other functions that share that upvalue will also be
changed. lua_upvaluejoin changes the upvalue reference. The tricky part
is that the new reference must also be the upvalue of another function.