-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathduplicateLastFrame.lua
More file actions
30 lines (28 loc) · 907 Bytes
/
duplicateLastFrame.lua
File metadata and controls
30 lines (28 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local spr = app.activeSprite
local originalSelectedLayer = app.activeLayer
local originalSelectedFrame = app.activeFrame
function duplicatePenultimateCel(layer)
local framesCount = #app.activeSprite.frames
if layer:cel(framesCount-1) ~= nil then
local image = Image(layer:cel(framesCount-1).image, spr.colorMode)
spr:newCel(layer, framesCount)
layer:cel(framesCount).image = image
layer:cel(framesCount).position = layer:cel(framesCount-1).position
end
end
app.transaction(
function()
local framesCount = #app.activeSprite.frames
for i,layer in ipairs(spr.layers) do
if layer:cel(framesCount) ~= nil then
spr:newEmptyFrame()
for i,layer in ipairs(spr.layers) do
duplicatePenultimateCel(layer)
end
app.activeLayer = originalSelectedLayer
app.activeFrame = originalSelectedFrame
break
end
end
end
)