-
Notifications
You must be signed in to change notification settings - Fork 2
Environment
The environment defines what things are visible to Lua as well as global variables and methods. The hosting environment can create and maintain multiple environments and change them if desired. An indexer on the environment will get/set the global variable with that key. The hosting environment can create a new Environment by calling the constructor and passing settings to it. Changing Lua.Environment will change the environment passed to new chunks, changing this value while parsing is impossible. If Lua.Environment is changed, any chunks that are already loaded will maintain the old environment. The hosting environment can change LuaChunk.Environment to change the environment that the chunk will execute in.
If a method is returned to .NET and passed into Lua code that belongs to a different environment, it will execute as if it is in the old environment and will pass it's environment to any object it creates. Other objects do not maintain the environment they were created in. Changing LuaChunk.Environment during execution is impossible.
The only public method on an environment is Save which saves a .dll file of the compiled Lua code. This can be loaded the same way as source code or can be loaded by the ModuleBinder. This code contains types and methods for all chunks that were loaded into it. If Lua.Environment is changed, it will be saved in a different assembly. The library can only save the file in the executable directory and move it to the destination path.
Next: Lua Code