List of active sprites

since i started to save sessions i have dozens of files opened at once, so i needed this.
it’s just a dialog with drop down menu of all opened sprites, so you can switch between sprites.
won’t work without sprites.

-- SPRITE LIST 0.01 
-- b236 
-- ATTENTION: no sprites = no fun! 

local asprt = app.sprite
local sprts = {}

function getSprites() 
	for i,sprite in ipairs(app.sprites) do
	  table.insert(sprts, sprite.filename) 
	end 
	for i = 1, #sprts//2, 1 do
        sprts[i], sprts[#sprts-i+1] = sprts[#sprts-i+1], sprts[i]
    end
end 

getSprites() 

function clearList() 
	for i in pairs(sprts) do 
        sprts[i] = nil 
    end  
end 

function switchTo(filet)
	for i, sprite in ipairs(app.sprites) do
        if sprite.filename == filet then
            app.sprite = app.sprites[i]
        end
    end
end

dlgW = Dialog("*** SPRITES ***  ") 
	:combobox{ id = "lst",
		option = asprt.filename,
		options = sprts,
		onchange = function()
			switchTo(dlgW.data.lst)
		end
	}
	
	dlgW:button{ id="exit", text="Close", onclick=function() 	-- i still don't get this dlgW thing here
		clearList() 
		dlgW:close() 
	end} 

dlgW:show{wait=false}