Editing
Export Aseprite Tileset
From F256 Foenix
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====== This LUA script file needs to be placed in Aseprite's "scripts" folder. ====== -- export tileset.lua -- Copyright (C) 2022 Daniel Tremblay -- -- This file is released under the terms of the MIT license. 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="filename", label="Export to Tilemap file:", save=true, focus=true, filename=app.fs.joinPath(app.fs.filePath(lay.sprite.filename), "tileset.png") } :label{ label="Number of Tiles to be exported", text=tostring(#tileset) } :separator() :number { id="tilemap_cols", label="Number of columns in Tilemap:", text="16" } :check { id="ask_overwrite", label="Ask before overwrite existing Tilemap file", selected=true } :check { id="tiles_extruded", label="Extrude Tiles in Tilemap", selected=false } :check { id="keep_sprite_frames", label="Keep generated sprite frames open", selected=false } :check { id="open_generated", label="Open generated Tilemap", selected=false } :separator() :button{ text="&Export", focus=true, id="ok" } :button{ text="&Cancel" } :show() -- Data validation local data = dlg.data if not data.ok then return end local spec = lay.sprite.spec local grid = tileset.grid local size = grid.tileSize -- Create a new sprite with the dimension of one single tile local newSpr = Sprite(size.width, size.height, lay.sprite.colorMode) -- give the new sprite the same palette as the source sprite newSpr:setPalette(lay.sprite.palettes[1]) -- First copy first tile into sprite frame 1 local tile = tileset:getTile(0) newSpr.cels[1].image = tile -- Then create new frame and copy each tile into a new frame of sprite for i = 1, #tileset - 1 do app.command.NewFrame { ["content"]="current" } local tile = tileset:getTile(i) newSpr.cels[i + 1].image = tile end if app.apiVersion >= 3 then newSpr.filename = "sprite frames" end -- Export sprite frames as an extruded sprite sheet app.command.ExportSpriteSheet{ ui=false, askOverwrite=data.ask_overwrite, type=SpriteSheetType.ROWS, columns=data.tilemap_cols, textureFilename=data.filename, extrude=data.tiles_extruded, openGenerated=data.open_generated } -- Close sprite frames again if data.keep_sprite_frames == false then newSpr:close() end
Summary:
Please note that all contributions to F256 Foenix are considered to be released under the Creative Commons Zero (Public Domain) (see
F256 Foenix:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
Edit source
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information