关闭Lua的状态并重新打开 [英] Close Lua State and Reopen
问题描述
我使用Lua的android系统,但不是很清楚,如果我能做到这一点:
I'm using Lua in android but is not very clear if I can do this:
LuaState L = null;
function loaddata(String data)
{
if ( L !=null && L.isClosed() == false)
L.close();
L = LuaStateFactory.newLuaState();
L.openLibs();
L.LdoString(data);
}
loaddata(string_1) ;
//and later
loaddata(string_2);
我要清除的L和与其他数据的使用, STRING_2
。
请问我的功能 L.LdoString(数据);
有相应的 STRING_2
一个新的数据?
还是会 STRING_1
加上 STRING_2
在→
?
I want to clear the L and use it with another data, string_2
.
Will my function L.LdoString(data);
have a new data corresponding to string_2
?
Or will it be string_1
plus string_2
in the L
?
推荐答案
在您的code,当你调用 L.close()
您关闭现有的LUA状态。
In your code when you call L.close()
you are closing the existing lua state.
您再使用 LuaStateFactory.newLuaState()
以创建一个新的(干净)LUA的状态。
You then use LuaStateFactory.newLuaState()
to create a new (clean) lua state.
从previous调用该函数什么都不会在新的状态退出。
Nothing from a previous call to that function will exit in the new state.
(我假设的功能在这里,因为他们似乎和相似的名称函数的C API函数工作。)
(I'm assuming the functions here work as they would appear to and as the C api functions of similar names function.)
这篇关于关闭Lua的状态并重新打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!