本文整理汇总了Java中org.keplerproject.luajava.LuaState类的典型用法代码示例。如果您正苦于以下问题:Java LuaState类的具体用法?Java LuaState怎么用?Java LuaState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaState类属于org.keplerproject.luajava包,在下文中一共展示了LuaState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initLuaContext
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
private void initLuaContext(LuaState luaState){
try {
JavaFunction logfunction = new LogFunctionCallBack(luaState);
logfunction.register("log");
JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
tostringfunction.register("tostring");
JavaFunction bindfunction = new BindClassCallBack(luaState);
bindfunction.register("bind");
JavaFunction reflecttion = new ReflectCallBack(luaState);
reflecttion.register("getMethod");
} catch (LuaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例2: initLuaContext
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
private void initLuaContext(LuaState luaState){
try {
JavaFunction logfunction = new LogFunctionCallBack(luaState);
logfunction.register("log");
JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
tostringfunction.register("tostring");
luaState.pushJavaObject(ModuleContext.getInstance().getAppContext().getApplicationContext());
luaState.setGlobal("context");
luaState.pushJavaObject(ZjDroidLuaJavaAPI.getInstance());
luaState.setGlobal("zjdroid");
} catch (LuaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: stackDump
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
static void stackDump (LuaState L) {
int i;
int top = L.getTop();
for (i = 1; i<=top; i++) {
int t = L.type(i);
if (t == LuaState.LUA_TSTRING) {
Log.v("String", L.toString(i));
} else if (t == LuaState.LUA_TBOOLEAN) {
Log.v("Boolean", String.valueOf(L.toBoolean(i)));
} else if (t == LuaState.LUA_TNUMBER) {
Log.v("Number", String.valueOf(L.toNumber(i)));
} else if (t == LuaState.LUA_TNIL) {
Log.v("Nil", "nil");
} else {
Log.v("Other", String.valueOf(L.typeName(i)));
}
}
}
示例4: sandbox
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public LuaState sandbox(String openid) {
LuaState lua = LuaStateFactory.newLuaState();
lua.openBase();
lua.openDebug();
lua.openMath();
lua.openString();
lua.openTable();
// 移除loadfile方法
lua.pushNil();
lua.setGlobal("loadfile");
return lua;
}
示例5: main
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public static void main(String[] args) throws LuaException {
LuaState lua = LuaStateFactory.newLuaState();
lua.openLibs();
lua.pushJavaObject(new Thread() {
public void run() {
System.out.println("Lua Thread?");
}
});
lua.setGlobal("t");
int re = lua.LloadString("function f() t:run() return 123 end return f()");
System.out.println(re);
lua.pcall(0, 1, 0);
System.out.println("re="+re);
System.out.println(lua.getTop());
System.out.println(lua.getLuaObject(1).getNumber());
Lang.quiteSleep(2000);
// System.out.println(System.currentTimeMillis());
}
示例6: initLuaContext
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
private void initLuaContext(LuaState luaState){
try {
JavaFunction logfunction = new LogFunctionCallBack(luaState);
logfunction.register("log");
JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
tostringfunction.register("tostring");
} catch (LuaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: invokeScript
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void invokeScript(String script){
LuaState luaState = LuaStateFactory.newLuaState();
luaState.openLibs();
this.initLuaContext(luaState);
int error = luaState.LdoString(script);
if(error!=0){
Logger.log("Read/Parse lua error. Exit");
return;
}
luaState.close();
}
示例8: invokeFileScript
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void invokeFileScript(String scriptFilePath){
LuaState luaState = LuaStateFactory.newLuaState();
luaState.openLibs();
this.initLuaContext(luaState);
int error = luaState.LdoFile(scriptFilePath);
if(error!=0){
Logger.log("Read/Parse lua error. Exit");
return;
}
luaState.close();
}
示例9: invokeScript
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void invokeScript(String script){
LuaState luaState = LuaStateFactory.newLuaState();
luaState.openLibs();
this.initLuaContext(luaState);
int error = luaState.LdoString(script);
if(error!=0){
Logger.log("Read/Parse lua error. Exit");
return;
}
luaState.close();
}
示例10: invokeFileScript
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void invokeFileScript(String scriptFilePath){
LuaState luaState = LuaStateFactory.newLuaState();
luaState.openLibs();
this.initLuaContext(luaState);
int error = luaState.LdoFile(scriptFilePath);
if(error!=0){
Logger.log("Read/Parse lua error. Exit");
return;
}
luaState.close();
}
示例11: onSuccess
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void onSuccess(int l, Header aheader[], byte abyte0[])
{
String s = Utils.getStringFromBytes(abyte0);
j j1;
j1 = (j)Utils.getGson().fromJson(s, cn/com/smartdevices/bracelet/lua/j);
if (j1.a != 1)
{
Debug.i("chenee", (new StringBuilder()).append("get latest luaZipFile error (message:").append(j1.b).append(")").toString());
return;
}
try
{
byte abyte1[] = Base64.decode(j1.c.b, 2);
LuaZipFile luazipfile = new LuaZipFile();
luazipfile.setVersion(j1.c.c);
luazipfile.setZipFile(abyte1);
LuaZipFileDao luazipfiledao = DaoManager.getInstance().getLuaZipFileDao();
luazipfiledao.insertOrReplace(luazipfile);
Keeper.keepLatestDBLuaVersion(j1.c.c);
Debug.i("chenee", (new StringBuilder()).append("save DB luaZipFile onSuccess====(version:").append(j1.c.c).append(")").toString());
a.resetLuaState();
LuaState luastate = a.getLuaState();
luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "setLocale");
luastate.pushString(Locale.getDefault().toString());
a.callLua(1, 0);
Debug.i("chenee", (new StringBuilder()).append("zipfile count:").append(luazipfiledao.count()).toString());
return;
}
catch (Exception exception)
{
Debug.e("chenee", (new StringBuilder()).append("get latest lua gson error!:").append(exception.getMessage()).toString());
}
return;
}
示例12: doLuaAction
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void doLuaAction(String s)
{
Debug.i("chenee", (new StringBuilder()).append("-------------\n").append(s).toString());
Debug.i("chenee", "--------------------\n");
LuaManager luamanager = LuaManager.getInstance();
LuaState luastate = LuaManager.getInstance().getLuaState();
luastate.LdoString(s);
luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "doAction");
luastate.pushJavaObject(context);
luastate.pushJavaObject(__instance);
luamanager.callLua(2, 0);
}
示例13: callLuaFunc
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public void callLuaFunc(String s, EventGameUpdate eventgameupdate)
{
LuaManager luamanager = LuaManager.getInstance();
LuaState luastate = luamanager.getLuaState();
luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), s);
eventgameupdate.getConfigInfo().setLuaAction(context);
luastate.pushJavaObject(DaoManager.getInstance().getLuaListDao());
luastate.pushJavaObject(eventgameupdate.getConfigInfo());
luamanager.callLua(2, 0);
}
示例14: getGameInfo
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public String getGameInfo()
{
setLocale(Locale.getDefault().toString());
LuaManager luamanager = LuaManager.getInstance();
LuaState luastate = luamanager.getLuaState();
luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getGameInfo");
luastate.pushJavaObject(cInfo);
luamanager.callLua(1, 0);
Debug.i("LuaEvent", (new StringBuilder()).append("get lua game info =").append(cInfo.getGameInfo()).toString());
return cInfo.getGameInfo();
}
示例15: getLuaVersion
import org.keplerproject.luajava.LuaState; //导入依赖的package包/类
public String getLuaVersion()
{
LuaManager luamanager = LuaManager.getInstance();
LuaState luastate = luamanager.getLuaState();
luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getLuaVersion");
luastate.pushJavaObject(cInfo);
luamanager.callLua(1, 0);
String s = cInfo.getLuaVersion();
Debug.i("LuaEvent", (new StringBuilder()).append("get lua version from local =").append(cInfo.getLuaVersion()).toString());
return s;
}