# Create New Continuous Layer

**URL:** https://community.aseprite.org/t/create-new-continuous-layer/13502
**Category:** Scripts & Extensions
**Created:** [March 19, 2022, 3:21am UTC](https://community.aseprite.org/t/create-new-continuous-layer/13502 "2022-03-19T03:21:28Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Olga\_Galvanova](https://community.aseprite.org/user_avatar/community.aseprite.org/olga_galvanova/32/3294_2.png) [@Olga\_Galvanova](https://community.aseprite.org/u/Olga_Galvanova)
#### Post date: [March 19, 2022, 9:45am UTC](https://community.aseprite.org/t/create-new-continuous-layer/13502/4 "2022-03-19T09:45:30Z")

</div>

added couple of lines to add new layer above current active layer + name new layer as "Layer " + number:

```auto
app.transaction(function()
    local sprite = app.activeSprite
	local index = app.activeLayer.stackIndex 
	local stack = #sprite.layers 

    -- Create a new layer
    local newLayer = sprite:newLayer()
    newLayer.isContinuous = true 

    -- Creat a cel in the first frame of the layer, without this cels won't link
    sprite:newCel(newLayer, 1)

    -- Get all of the frame numbers into a table/array
    local frames = {}
    for frameNumber, _ in ipairs(sprite.frames) do
        table.insert(frames, frameNumber)
    end

    -- In order to select cels in range we need to specify both layers and frame - cels are their intersection
    app.range.frames = frames
    app.range.layers = {newLayer}

    app.command.LinkCels() 
	
    app.range:clear()
	
	newLayer.stackIndex = index + 1
	newLayer.name = "Layer " .. stack + 1 
end)

```

---

_[View the full topic](https://community.aseprite.org/t/create-new-continuous-layer/13502)._
