Iterate through all the layers in the project

local count = 0
repeat
local layer = moho.document:LayerByAbsoluteID(count)
if layer then
count = count + 1
-- do whatever you like with the layer, for example print the name:
print(layer:Name())
end
until not layer
print("Total number of layers in the project: " .. count)