Re: Github mirror
I had a quick attempt at this last night, but it occurred to me that any solution is going to be difficult and seem pretty hacked in. There is no real concept of a lua environment that I can add to because the lua_State gets cleared when you start a new scene. In the MScriptableBehaviour component I have sort of worked around this by (re)loading the relevant behaviour script whenever a behaviour of that type is created, which obviously has a number of issues.
I have come up with the following possible solutions:
1. Create an event system that you can subscribe to, so if you get an event of MEventScriptEnvironmentInit then you know to load the scripts at the right time
2. Be able to add to the environment by cacheing the scripts. This is probably the easiest solution, but would require to keep a local copy of all environment scripts in memory, or to write them to temporary files...
3. Use something like lua rings, which will allow multiple states to be active, so we could pretty much have the event system in lua, and the master (environment) state could set up a recreated slave (game) state.
Unfortunately, my "ideal" solution of having a clean environment state that we clone doesn't seem like an option, I haven't found any way of cloning a state (yet)
Last edited by Nistur (2013-06-28 08:39:43)