A set of functions to handle the clipboard.
When calling a function with clipboard write access in a script, Aseprite will ask the user if they want to allow the function to run or stop the script.
local text = app.clipboard.textGets or sets the clipboard text. Returns nil if there is no text.
local image = app.clipboard.imageGets or sets the clipboard image. Returns nil if there is no image. It is recommended to set/get the value once when needed, as the operation may not always be available immediately (in some instances it may take a few milliseconds, see #5341).
Additionally, when calling a method on an image from the clipboard image, the image should be saved to a variable first, instead of calling the method directly on the property (this will not work: app.clipboard.image:clear(), see #5341)
local content = app.clipboard.contentGets the content of the clipboard, as a table. Values:
image: An image object ornilselection: A selection object ornilpalette: A palette object orniltileset: A tileset object orniltext: A string ornil
Depending on what is copied, each value will be set differently. Case table:
| An image is copied in Aseprite | An image is copied externally | Text is copied | A portion of the Palette is copied | |
|---|---|---|---|---|
image |
Image | Image | nil |
nil |
selection |
Selection | nil |
nil |
nil |
palette |
Sprite palette | nil |
nil |
nil |
tileset |
nil |
nil |
nil |
nil |
text |
nil |
nil |
String | String of selected colors in hex codes, separated by \n |
local hasText = app.clipboard.hasTextReturns true if the last item copied to the clipboard was text.
local hasImage = app.clipboard.hasImageReturns true if the last item copied to the clipboard was an image.
app.clipboard.clear()Clears the clipboard.
