Hi everyone,
I am very new to LUA and scripting for Aseprite and I can’t get the SaveFileCopyAs function to work.
Here is my code:
local nameList = {"firstName", "secondName", "thirdName"}
for i=1, #(app.sprite.frames) do
app.command.SaveFileCopyAs {
ui=false,
filename= nameList[i],
fromFrame = i-1,
toFrame = i-1
}
end
Basically, it should cycle through every frame and then save that frame with a specified exportName (e.g., “firstName”, “secondName”, etc.).
The for loop diligently goes through the code for the amount of frames in the active sprite.
The first frame usually gets exported correctly. However, sometimes I get the “Saving an animation as a sequence of static images”-Alert. The second frame always triggers this prompt. When clicking no, the export stops (which is fine), when clicking yes, the second export will be “secondName1” and “secondName2” with frame 1 and frame 2 respectively.
I believe, the fromFrame and toFrame arguments somehow do not quite work. I tried using toFrame = i+1
in case it is exclusive, but then I get out of bounds errors.
Any idea how I correctly use these arguments? I am starting to think this might be a bug.
Happy for any tips or workarounds.
Thanks in advance!
Edit:
On a sidenote: my original code had fromFrame=i, toFrame=i
since i assumed the frame number checked by SaveFileCopyAs was the same as the number in “app.range.frames”, but I think wherever array/list/whatever SaveFileCopyAs looks starts at 0, not 1. It is a bit confusing