private void loadSystemPackage(ClassLoader resourceLoader, String packageName) { String resourcePath = "udf/" + packageName + ".lua"; Prototype prototype = LuaCache.loadPackageFromResource(resourceLoader, resourcePath, packageName); LuaClosure function = new LuaClosure(prototype, globals); function.invoke(); loadedTable.set(packageName, LuaValue.TRUE); }
private void loadSystemPackage(ClassLoader resourceLoader, String packageName) { String resourcePath = "udf/" + packageName + ".lua"; Prototype prototype = LuaCache.loadPackageFromResource(resourceLoader, resourcePath, packageName); LuaClosure function = new LuaClosure(prototype, globals); function.invoke(); loadedTable.set(packageName, LuaValue.TRUE); }
@Override public Object proceedGame(long aGameTime, long aElapsedTimeSinceLastLoop) { Varargs theArguments = LuaValue.varargsOf(new LuaValue[] { LuaInteger.valueOf(aGameTime), LuaInteger.valueOf(aElapsedTimeSinceLastLoop) }); LuaClosure theMethodToCall = (LuaClosure) globals.get(LuaString.valueOf(methodName)); Varargs theResult = theMethodToCall.invoke(theArguments); if (theResult.narg() == 1) { return toJavaValue(theResult.arg(1)); } throw new IllegalStateException("Not supported return type : " + theResult + " for function " + methodName); }
@Override public String evaluateSimpleExpressionFor(GameObjectInstance aObjectInstance) { Varargs theArguments = LuaValue.varargsOf(new LuaValue[] { toLuaValue(aObjectInstance, cache), toLuaValue(aObjectInstance.getOwnerGameObject().getGameScene(), cache), toLuaValue(aObjectInstance.getOwnerGameObject().getGameScene().getGame(), cache), }); LuaClosure theMethodToCall = (LuaClosure) globals.get(LuaString.valueOf(methodName)); Varargs theResult = theMethodToCall.invoke(theArguments); if (theResult.narg() == 1) { return toJavaValue(theResult.arg(1), String.class).toString(); } throw new IllegalStateException("Invalid return type : " + theResult); } }
public void loadPackage(Statement statement) { if (loadedTable.get(statement.getPackageName()).toboolean()) { return; } Prototype prototype; if (statement.getResourceLoader() == null || statement.getResourcePath() == null) { prototype = LuaCache.loadPackageFromFile(statement.getPackageName()); } else { prototype = LuaCache.loadPackageFromResource(statement.getResourceLoader(), statement.getResourcePath(), statement.getPackageName()); } LuaClosure function = new LuaClosure(prototype, globals); function.invoke(); loadedTable.set(statement.getPackageName(), LuaValue.TRUE); }
public void loadPackage(Statement statement) { if (loadedTable.get(statement.getPackageName()).toboolean()) { return; } Prototype prototype; if (statement.getResourceLoader() == null || statement.getResourcePath() == null) { prototype = LuaCache.loadPackageFromFile(statement.getPackageName()); } else { prototype = LuaCache.loadPackageFromResource(statement.getResourceLoader(), statement.getResourcePath(), statement.getPackageName()); } LuaClosure function = new LuaClosure(prototype, globals); function.invoke(); loadedTable.set(statement.getPackageName(), LuaValue.TRUE); }