OK, first off, all this Lua environments concept is something I didn't thought I had to deal with, so I'm very green treating to speak about them, but I'll try to do my best...
Until now, I've not had to deal with all this because most of the scripts I've done for the animation program Moho were simple "Tool Scripts" and those, as tools in any other program, has more to do with user interaction than with rendering; but now I'm into developing what are called "Embedded Scripts", which consist in Lua files you can embed to any layer along the Moho project and are run several times upon any change for doing whatever they has to do. I hope to be raising it well....
Well, the problem I'm facing that I didn't have to face before is the program seems to be creating a new/different Lua environment for rendering than the one you normally work with and, therefore, once the program starts rendering, the script is unable to get any global variable you could have stored before from the other one.
So (in the end) the question is... Is there any possibility I can pass some global variables from the first environment to the other new & fresh one? (And, if so, how to know which is which?) Because none of the global variables I had stored before starting to render seem to exist in the new one (I think for obvious reasons, being different environments) and that makes impossible to get these kind of embedded scripts work as soon as they need to call a function or variable previously created/instanced, due to they are not found in this other environment and all you get is the typical "attempt to call '?' (a nil value)" Lua Console error jumping and the entire script being ignored.
Sorry for all that introduction, but I thought it could somehow help to better understand the situation, which seems pretty bad to me since the hosting program puts the rules and limits regarding what I can do or not (I can't even require modules due to a know bug) and the only way out I can see is find a way to can pass this global variables between these different environments... Greetings and thanks in advance for any help.
Maybe it will help to design your functions to use an environment from argument list if it exists?