I try to save/serialize a Lua state. I know, that I had to save/serialize all globals, which I find in _G, but didn't know how to save/serialize the LuaFunctions I find. I tried to use string.dump
, but that delivers only a string with the Lua signature (5 bytes with LuaQ).
The function string.dump
works, because if I call
lua.DoString("print(string.len(string.dump(CountItems)))");
I get 409 instead of 5 as the length of the string. So the dump works correct. It could be a problem in LuaInterface.
Is there someone out there, how realized a serialization of a Lua state via LuaInterface?
Best regards, Dirk
PS: I'm using KopiLua 5.1.4 with LuaInterface 2.0.4 on VS 2010 C# Express.
Solved.
The problem was, that the binary chunk, which string.dump
returns, was handled as a string. So it was cut at the first null byte in the string, which was after 5 bytes. Changed the call of DoString
, so that it handles byte arrays correct.