use of org.luaj.vm2.LuaError in project pixel-dungeon-remix by NYRDS.
the class LuaEngine method module.
@Nullable
public static LuaTable module(String module, String fallback) {
LuaValue luaModule = getEngine().call("require", module);
if (luaModule.istable()) {
return luaModule.checktable();
}
EventCollector.logEvent("LuaError", "failed to load lua module:", module);
luaModule = getEngine().call("require", fallback);
if (luaModule.istable()) {
return luaModule.checktable();
}
EventCollector.logEvent("LuaError", "failed to load fallback lua module:", fallback);
return null;
}
use of org.luaj.vm2.LuaError in project pixel-dungeon-remix by NYRDS.
the class LuaEngine method call.
public LuaValue call(String method, Object arg1, Object arg2) {
try {
LuaValue methodForData = globals.get(method);
methodForData.call(CoerceJavaToLua.coerce(arg1), CoerceJavaToLua.coerce(arg2));
} catch (LuaError err) {
reportLuaError(err);
}
return LuaValue.NIL;
}
use of org.luaj.vm2.LuaError in project love-android by hagish.
the class LoveConfig method loadFromFileStream.
public void loadFromFileStream(InputStream configFileInputStream) throws IOException {
LuaTable g = JsePlatform.debugGlobals();
g.set("love", new LuaTable());
try {
LoadState.load(configFileInputStream, "conf.lua", g).call();
} catch (LuaError e) {
// ~ vm.handleLuaError(e);
// ignored
}
LuaValue conf = LuaUtils.getFromTableByPath(g, "love.conf");
if (!conf.equals(LuaValue.NIL)) {
LuaTable t = new LuaTable();
t.set("modules", new LuaTable());
t.set("screen", new LuaTable());
try {
conf.call(t);
} catch (LuaError e) {
// ~ vm.handleLuaError(e);
// ignored
}
loadFromLuaTable(t);
}
}
use of org.luaj.vm2.LuaError in project LuaViewSDK by alibaba.
the class LuaViewManager method bindMethods.
/**
* bind lua functions using method
*
* @param factory
* @param methods
* @return
*/
public static LuaTable bindMethods(Class<? extends LibFunction> factory, List<Method> methods) {
LuaTable env = new LuaTable();
try {
if (methods != null) {
for (int i = 0; i < methods.size(); i++) {
LibFunction f = factory.newInstance();
f.opcode = -1;
f.method = methods.get(i);
f.name = methods.get(i).getName();
env.set(f.name, f);
}
}
} catch (Exception e) {
throw new LuaError("[Bind Failed] " + e);
} finally {
return env;
}
}
use of org.luaj.vm2.LuaError in project LuaViewSDK by alibaba.
the class LuaViewManager method bind.
/**
* bind lua functions using opcode
*
* @param factory
* @param methods
* @return
*/
public static LuaTable bind(Class<? extends LibFunction> factory, String[] methods) {
LuaTable env = new LuaTable();
try {
if (methods != null) {
for (int i = 0; i < methods.length; i++) {
LibFunction f = factory.newInstance();
f.opcode = i;
f.method = null;
f.name = methods[i];
env.set(f.name, f);
}
}
} catch (Exception e) {
throw new LuaError("[Bind Failed] " + e);
} finally {
return env;
}
}
Aggregations