+ {
+ Glib::Threads::Mutex::Lock lm (lua_lock);
+ std::string saved;
+ {
+ luabridge::LuaRef savedstate ((*_lua_save)());
+ saved = savedstate.cast<std::string>();
+ }
+ lua.collect_garbage ();
+ lm.release ();
+
+ gchar* b64 = g_base64_encode ((const guchar*)saved.c_str (), saved.size ());
+ std::string b64s (b64);
+ g_free (b64);
+
+ XMLNode* script_node = new XMLNode (X_("Script"));
+ script_node->add_property (X_("lua"), LUA_VERSION);
+ script_node->add_content (b64s);
+ node->add_child_nocopy (*script_node);
+ }
+