Hi, I’m trying to make a simple script to flip the red channel of a selection to make normal maps quicker. I’d like to have a single shortcut for both the channel inversion and the flip horizontal. But I can’t find anything in the API and the function just flips the entire screen, it doesn’t even care about my parameters.
vertical and horizontal (or no params at all) flips the screen horizontally.
Has anyone managed to make a flip on a selection via scripting? Thanks!
Here is what I have so far:
local lay = app.activeLayer
if not lay then return app.alert "There is no active layer" end
app.transaction(
function()
app.command.InvertColor {
ui=false,
channels=FilterChannels.RED
}
app.command.Flip{
target=mask,
orientation=vertical
}
end)
Thank you very much! It indeed works, but now I have an error in aseprite after the script executed. If i click anywhere, it brings the console and say “A problem has occurred. Details: cannot modify the sprite. It is being used by another command. Try again”.
Is this the case on your side when executing the script?
I tried to look at the code and the API but, me not being a developer, my understanding of all this is quite limited.
Now that I tried the script in full, that error message showed up for me… one of the reasons I try to avoid commands . See if this hack of inverting the mask twice works.
local lay = app.layer
if not lay then return app.alert "There is no active layer" end
app.transaction("Flip Normal Map", function()
app.command.Flip {
target = "mask",
orientation = "vertical"
}
app.command.InvertMask()
app.command.InvertMask()
app.command.InvertColor {
ui = false,
channels = FilterChannels.RED,
}
app.command.InvertMask()
app.command.InvertMask()
end)
app.refresh()