public static ILayer getLayerArg(Varargs args, int index) throws ScriptException { if (args.isuserdata(index)) { ILayer layer = args.touserdata(index, ILayer.class); if (layer != null) { return layer; } } else if (args.isnil(index)) { return null; } throw new ScriptException("Invalid layer arg: " + args.tojstring(1)); }