Last active
October 24, 2024 16:54
-
-
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{ filename=data.file, palette=lay.sprite.palettes[1] } | |
-- Open exported file? | |
--app.open(data.file) | |
end |
Is there a way to fix the palette problem? I'm currently facing an engine limitation where my sprites larger than 64x64 must be composed of different pieces (Eg: a 128x128 sprite must be made from 4 64x64 smaller sprites arranged).
And the palette problem is crucial: The engine only supports 16 colours per sprite...
I've just updated the script to export the correct palette. I'm seeing another issue now that the exported file contains the first palette entry totally transparent.
@sigmasoldi3r could you check if this script now works for you?
It works! The palette is exported now, thanks!
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.