Skip to content

Instantly share code, notes, and snippets.

Last active January 28, 2023 08:45
What would you like to do?
basic aseprite to picotron exporter

picotron is in early alpha -- it doesn't seem to have a sprite editor yet but it does support sprites in a particular format, so I threw together this quick-and-dirty aseprite exporter. hopefully this exporter will be obsolete soon!


you'll need Aseprite to use this.

this script is Windows-only, because of the io.popen('clip' ... str) -- "clip" is a windows executable. but you can replace that with print(str) and manually press ctrl-c on the popup window and it should work (don't close the popup afterwards or you'll need to re-open the script)

how to use

  1. save this script to your aseprite scripts folder (File > Scripts > Open Scripts Folder) then reopen aseprite (or rescan scripts)
  2. load an image with the picotron palette (or pico-8 extended palette)
  3. change the image's color mode to "indexed" (Sprite > Color Mode > Indexed)
  4. launch this script, press "copy" to copy to clipboard.
  • if there is a current selection, it will only copy that region
  • leave the script window open to copy again later
  1. see the picotron alpha release notes for info on how to use the string in your clipboard. it should looks something like [gfx]08080000000000000000000000000700707007777007717177700777777000607070[/gfx]

how does it work

it converts pixels into picotron's gfx format: "[gfx]", 2-char hex width, 2-char hex height, WxH chars of color data, "[\gfx]".

the color data is "extended hexadecimal", i.e. 0=>"0", ... 15=>"f", 16=>"g", ... 31=>"v"


you can use this for pico8 too; just copy and you can to paste directly into the pico8 sprite editor. note that it will likely only work with the first 16 colors

-- Pico[8|tron] Export
-- by pancelor
-- a simple script to export the entire sprite (or current selection)
-- in the pico8 format, e.g.
-- [gfx]08080000000000000000000000000700707007777007717177700777777000607070[/gfx]
function add(tab,elem)
return elem
-- 0=>"0", ... 15=>"f", 16=>"g", ... 31=>"v"
local function picohex(val)
if 0<=val and val<=9 then
return string.char(0x30+val)
elseif 10<=val and val<=31 then
return string.char(97+val-10)
assert(nil,"bad val for picohex: "..val)
-- copy string to host clipboard
-- windows-only
local function xsel(str)
-- print(str) --non-windows systems (requires manual ctrl-c)
# main
local dlg = Dialog("Pico Export")
dlg:button{text="Copy", onclick=function()
local cel=app.activeCel
if not cel then return app.alert("error: no sprite found") end
if cel.image.colorMode~=ColorMode.INDEXED then return app.alert("sprite palette must be indexed") end
-- rect: the subrectangle to export tiles from
local rect=app.activeSprite.selection.isEmpty and app.activeSprite.bounds or app.activeSprite.selection.bounds
local build={}
for dy=0,rect.height-1 do
for dx=0,rect.width-1 do
local col = cel.image:getPixel(rect.x+dx,rect.y+dy)
local ix = app.pixelColor.tileI(col)
-- dlg:label{ text="(then ctrl-c)" } --non-windows systems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment