Jump to content

chibubong

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by chibubong

  1. On 1/24/2022 at 11:41 AM, Tokei said:

    There are many ways to achieve that:

    foreach (var action in act) {
    	action.Frames = action.Frames.Take(1).ToList();
    }

    If you need more... "control" with indexes and which animations to remove exactly, you can do it this way too:

    for (int aid = 0; aid < act.Actions.Count; aid++) {
    	for (int fid = act.Actions[aid].Frames.Count - 1; fid >= 1; fid--) {
    		act[aid].Frames.RemoveAt(fid);
    	}
    }

    If you want to apply this to a batch of files, you can do it this way too:

    var path = @"C:\Sprites\";
    
    foreach (var file in Directory.GetFiles(path, "*.act")) {
    	var actFile = new Act(file);
    	
    	actFile.Actions.ForEach(p => p.Frames = p.Frames.Take(1).ToList());
    	actFile.Save(file);
    }

     

    I can't make this script work, it is not running and no errors were also given. 

×
×
  • Create New...