Skip to content

Latest commit

 

History

History
160 lines (110 loc) · 3.72 KB

File metadata and controls

160 lines (110 loc) · 3.72 KB

Range

This class is used to represent the range of selected objects.

For example:

Timeline Example

It can be:

  • A list of layers
  • A list of frames
  • A list of cels
  • A list of images
  • A list of colors
  • A list of slices

Or a combination of those.

Range.type

local type = app.range.type

Returns a RangeType.

Range.isEmpty

local booleanResult = app.range.isEmpty

Returns true if the range is empty, i.e. there is no selected range in the timeline (a thick border in the timeline), only the active cel in the sprite editor.

This is the same as asking for app.range.type == RangeType.EMPTY.

Note that if the range is empty, you can still use Range.layers to get the active layer (the Range.layers property will be an array of one element, just the active layer). The same is true for Range.frame and app.frame, Range.cel and app.cel, etc.

Range.sprite

The Sprite to which this range points.

Range.layers

local layers = app.range.layers
app.range.layers = { layer1, layer2, ... }

Returns or sets the array of selected layers.

Note that the array is sorted chronologically, in order of when the layers were created. The order does not match the order seen on the timeline, nor the order in which they were selected.

Range.frames

local frames = app.range.frames
app.range.frames = { 1, 2, ... }

Returns or sets the array of selected frames.

Range.cels

Returns an array of selected cels.

Range.images

Returns an array of selected images (images from linked cels are counted only once in this array).

Range.editableImages

Returns an array of selected images in the range that are in unlocked layers (editable).

Range.colors

local selectedColors = app.range.colors
app.range.colors = { ... }

Gets or sets the array of selected palette entries in the color bar. Each element of the array is an integer (the palette index)

Example to select the colors with index 0 and 3 in the color bar:

app.range.colors = { 0, 3 }

Range.tiles

local selectedTiles = app.range.tiles
app.range.tiles = { ... }

Gets or sets the array of selected tile entries in the color bar when we are in a tilemap layer. Each element of the array is an integer (the tile index).

Example to select tiles with index 0 and 3 in the color bar:

app.range.tiles = { 0, 3 }

Range.slices

local selectedSlices = app.range.slices
app.range.slices = { ... }

Gets or sets the array of selected slices in the sprite editor. Each element of the array is a slice.

Example to select all slices in the sprite:

app.range.slices = app.sprite.slices

Range:contains()

local hasLayer = app.range:contains(layer)
local hasFrame = app.range:contains(frame)
local hasCel = app.range:contains(cel)
local hasSlice = app.range:contains(slice)

Returns true if the given object (layer/frame/cel/slice) is inside the selected range.

Range:containsColor()

local hasColor = app.range:containsColor(colorIndex)

Returns true if the given color index is selected in the color bar.

Range:clear()

app.range:clear()

Clears the current selected range of frames/layers/cels/colors.