Calling a layer via script by its name inside a for loop

welcome, iiiikoooo.
sprite.layer api/sprite.md at main · aseprite/api · GitHub is only array and
layer.name api/layer.md at main · aseprite/api · GitHub only serves to get or set the name and it returns a string.
so i don’t think sprite.layer.name.isVisible will work.

i guess what you want to do is loop through the stack of layers (the array stored in sprite.layers) and ask with if condition if layer.name == "whatevername". if it does meet the requirements, then you set visibility with layer.isVisible = false.

something like this:

layername = "name"
local sprite = app.activeSprite
for i, layer in ipairs(sprite.layers) do
  if layer.name == layername then 
     layer.isVisible = false
  end
end
2 Likes