lua-users home
lua-l archive

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



On 02/08/2007, at 5:48 PM, Tom Miles wrote:


We know that the environment 1 code is called before environment 2, yet the results are the ouput is:
1
nil


From what I can see of your code you are making multiple Lua states. When you "require" something it is like a '#include <file>' in C, you get a copy of the code, not a shared state. Thus, the variables in Utilities.lua are independent from one state to the next. Of course, if you "require" something twice in a single Lua state then its variables are shared, because it is being loaded into the same state.

- Nick