@Override
public LuaValue call(LuaValue arg) {
try {
LuaTable table = arg.checktable();
String animationName = table.get("name").checkjstring();
String srcImageName = table.get("src_image").checkjstring();
int frameDelay = table.get("frame_delay").optint(0);
int frameToLoopOn = table.get("frame_to_loop_on").optint(-1);
LuaTable directionsTable = table.get("directions").checktable();
BufferedImage srcImage = null;
try {
if (!srcImageName.equals("tileset")) {
srcImage = Project.getProjectImage("sprites/" + srcImageName);
}
else if (!tilesetId.isEmpty()) {
srcImage = Project.getProjectImage(
"tilesets/" + Project.getTilesetEntitiesImageFile(tilesetId).getName());
}
} catch (IOException ex) {
// image cannot be loaded
}
Vector<SpriteAnimationDirection> directions = new Vector<SpriteAnimationDirection>();
// Traverse the directions table.
LuaValue key = LuaValue.NIL;
while (true) {
Varargs keyValue = directionsTable.next(key);
key = keyValue.arg1();
if (key.isnil()) {
break;
}
LuaValue directionTable = keyValue.arg(2);