I originally planned to have just one Lua VM for my entire project, but I've been trying to write an AI framework this past few days and I've decided that a separate VM for AI will actually work better. This way I can dynamically run all the AI scripts for all the agents in the game, then when the game ends or you load a previous game, I can just kill the VM and start over again without having to reinitialize everything else. Just the AI.
So I spent a couple of days rewriting my scriptengine so that it supports multiple VM's, and that's all good. But now I'm having problems if I define the same function in both VM's. If I don't define the function in both VM's, then I get an error when I try to use it, so that's right. Evidently the right VM is being used. But if I define the function in both, some completely unrelated scripts in the other VM are not being run at all. This makes absolutely no sense to me as you can probably imagine.
So I'm just posting to see if there are any problems inherent with multiple VM's which I might not have considered? The only thing which has really crossed my mind so far is that the stack might be getting trashed somehow, but I can't see how one VM could possibly have any effect on the stack of another.
So I spent a couple of days rewriting my scriptengine so that it supports multiple VM's, and that's all good. But now I'm having problems if I define the same function in both VM's. If I don't define the function in both VM's, then I get an error when I try to use it, so that's right. Evidently the right VM is being used. But if I define the function in both, some completely unrelated scripts in the other VM are not being run at all. This makes absolutely no sense to me as you can probably imagine.
So I'm just posting to see if there are any problems inherent with multiple VM's which I might not have considered? The only thing which has really crossed my mind so far is that the stack might be getting trashed somehow, but I can't see how one VM could possibly have any effect on the stack of another.