Jump to content
  • 0

ACT Editor: Script Runner For Each All Act Files


micjck2

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  1
  • Reputation:   0
  • Joined:  03/03/21
  • Last Seen:  

string folder = "C:/Users/medakas/data/sprite/¸ó½ºÅÍ/";                                     // Your folder that contains the .act files
DirectoryInfo d = new DirectoryInfo(folder);                                                // Loading the folder

foreach (var file in d.GetFiles("*.act")) {                                                 // Iterate each of the files
    Act act1 = new Act(file.FullName);                                                      // Loading the file as an Act data type
    act1.AnimationExecute(4, action => {action.Frames = new List<Frame> { new Frame() };}); // Removing the 4th layer/Dying Frames Animation
    act1.Save(act1.LoadedPath);                                                             // Saving The Edited/Transform act
}

I am trying to remove the dying animation of monsters of .act files. 

It works properly if I execute the script of the current open .act file -> means open an act file then run the script runner

act.AnimationExecute(4, action => {
    action.Frames = new List<Frame> { new Frame() };
});

Script Runner have a built in "act" variable which refers to the currently open windows in Act Editor. This works just fine but it is troublesome.

-----------------------------------------

In the first code block above, This remove the dying animation of the act files just fine, but the translate or position of the sprite got chaotic e.g. sometimes mobs are flying, sometimes in the ground, sometimes their body is in half.

 

 

The possible solution in my mind would be a proper loading of an Act File using the script runner which includes: frames, layers, and actions, retaining their original just altering 1 part. 

Any tips on implementing a script to all of the act files which does not reset the layers positions and any other settings. 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  659
  • Reputation:   664
  • Joined:  11/12/12
  • Last Seen:  

Heya,

The issue is that act files must be loaded with their sprite counterpart to function properly. The act file stores the width and height of the image for each layer and this data is loss otherwise (causing your position issues). The script works fine otherwise.

foreach (var file in Directory.GetFiles(@"C:\Users\medakas\data\sprite\¸ó½ºÅÍ\", "*.act")) {
    var act1 = new Act(file, file.ReplaceExtension(".spr"));
    
    act1.AnimationExecute(4, action => {
    	action.Frames = new List<Frame> { new Frame() };
    });
    
    act1.Save(file);
}

 

Edit: Actually, I looked more into it and that explanation turns out to be somewhat incorrect. At some point, the behavior was changed so that a Sprite object is automatically created if an Act object is created without specifying the Sprite path. The problem with that is that the saving function rewrites the Width/Height values if a Sprite object exists. Act Editor abstracts the Width/Height properties of the layers as that'd just be too annoying for the endusers to setup in the first place.

But this is a bug; if no image is associated with the layer with a Sprite present, it should not default to 0 Width/Height.

Edited by Tokei
  • Love 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...