Lua Scripting: Can you move a selection (SOLVED)

Hi :slight_smile:

I鈥檝e started toying with Aseprite scripts (this feature is amazing, I love it ^^), and while I鈥檓 really keen to try and script some useful things, I found myself stuckt in a problem.

When I try to move a selection that I previously made, I cannot get it to move where I want :frowning:
As far as I understand by looking at aseprite/gui.xml at master 路 aseprite/aseprite 路 GitHub , the command I must use should be something like:

app.command.MoveMask(target, direction, unity, quantity)

where:
target = sprite.selection (a selection that I previously told the script to create)
direction = 鈥渦p鈥/鈥渄own鈥/鈥渓eft鈥/鈥渞ight鈥 (one of these)
unity = 鈥減ixel鈥
quantity = 10 (10 pixels for example)

But no matter the values I give the function, the selection always moves just 1 pixel down. Not left nor up nor right, only down ^_^U

Could somebody please guide me a bit on this? Thanks in advance! :smiley:

Well, it seems that I am not the only one stuck at this problem. I think I鈥檓 a bit glad that I鈥檓 not alone XD

Please, o wise and almighty @Dacap , grant us the knowledge :bowing_man:

P.S: Should I have posted this on the 鈥淪cripts section鈥 instead?

Problem solved! :smiley:

David tested the MoveMask command and created some documentation about it here:

Here is the example code:

local spr = app.activeSprite
spr.selection = Selection(Rectangle(0,0,spr.width,spr.height))

app.command.MoveMask{
  target='content',
  direction='right',
  units='pixel',
  quantity=2,
  wrap=true
}

app.command.MoveMask{
  target='content',
  direction='up',
  units='pixel',
  quantity=2,
  wrap=true
}

app.command.DeselectMask()

Edit: Updated code. If you read the comment I wrote here yesterday about quotation marks, please forget it, because I was wrong (I鈥檝e deleted it from this post to avoid confussions).