I'm using LuaInterface for scripting in a game I'm making.
The scripting works quite nice, but somehow I'm getting a lot of random exceptions.
I've narrowed the problem down to where I call lua functions from C# code, which are invoked from another thread, handling networking with the gameserver.
I think what is happening, is that the lua code is being run, and lua functions are called from C# from another thread, which causes the random errors.
How I'm calling the functions from C#:
function.Call(message);
function is of type LuaFunction and message is a custom object.
Errors I'm getting:
Could it have to do with running lua functions from threads other than the thread the LuaVM was created on?
Lua is not thread safe. You either need to have a Lua state per thread and call the thread specific state, or place locks around any Lua calls.