Created
January 29, 2020 20:39
-
-
Save dacap/007e5a77efe231162ed8126dc9b20e1b to your computer and use it in GitHub Desktop.
Switches the visibility of two layers (Back/Front) at the same time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Switches the visibility of the active layer, if the layer is called | |
-- "Something Back" or "Something Front", it will try to switch the | |
-- visibility of the other layer "Something Back/Front" too (so you | |
-- can switch the visibility of two layers at the same time). | |
local layer = app.activeLayer | |
if not layer then | |
return app.alert "There is no active layer" | |
end | |
local name1 = layer.name:match('^(.+) Back$') | |
local name2 = layer.name:match('^(.+) Front$') | |
local otherLayer = nil | |
if name1 then | |
otherLayer = layer.sprite.layers[name1 .. " Front"] | |
elseif name2 then | |
otherLayer = layer.sprite.layers[name2 .. " Back"] | |
end | |
-- Customize this action in case that you want to do something | |
-- different on the active layer (and its Front/Back counter-part) | |
local function modifyLayer(l) | |
l.isVisible = not l.isVisible | |
end | |
-- Do something in the active "layer" and in the "otherLayer" | |
modifyLayer(layer) | |
if otherLayer then | |
modifyLayer(otherLayer) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment