Created
June 9, 2021 22:04
-
-
Save dacap/9df368ba276a45048dc85f96b23ea818 to your computer and use it in GitHub Desktop.
Export tileset
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
if TilesetMode == nil then return app.alert "Use Aseprite v1.3" end | |
local lay = app.activeLayer | |
if not lay.isTilemap then return app.alert "No active tilemap layer" end | |
local tileset = lay.tileset | |
local dlg = Dialog("Export Tileset") | |
dlg:file{ id="file", label="Export to File:", save=true, focus=true, | |
filename=app.fs.joinPath(app.fs.filePath(lay.sprite.filename), | |
lay.name .. ".png") } | |
:label{ label="# Tiles", text=tostring(#tileset) } | |
:separator() | |
:button{ text="&Export", focus=true, id="ok" } | |
:button{ text="&Cancel" } | |
:show() | |
local data = dlg.data | |
if data.ok then | |
local spec = lay.sprite.spec | |
local grid = tileset.grid | |
local size = grid.tileSize | |
spec.width = size.width | |
spec.height = size.height * #tileset | |
local image = Image(spec) | |
image:clear() | |
for i = 0,#tileset-1 do | |
local tile = tileset:getTile(i) | |
image:drawImage(tile, 0, i*size.height) | |
end | |
image:saveAs(data.file) | |
-- Open exported file? | |
--app.open(data.file) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful script, thanks! But it exports images with indexed colors as black-white.