update: there are basically 3 tools that are relevant here:
- this tool (sprimp) -- maybe still useful, but superceded by p8x8:
- p8x8: a tool to fully convert PICO-8 carts to Picotron carts (some assembly required) -- this grew out of sprimp
- my aseprite exporter plugin -- still useful
You probably want to check out p8x8 instead, but I'm leaving this thread as it is since it may still be useful or interesting to some people.
tada! now you can import pico8 spritesheets. and map too!
importing a .p8 file
- put your game.p8 file somewhere inside picotron's file system
- the filename should not have any dashes ("-"), they generally cause problems currently (picotron 0.1.0b2)
- run this importer (sprimp)
- import the p8 cart
- you can drag-and-drop the cart onto the sprimp window
- or you can use "Import .p8 file" in the menu (the dialog that pops up says "save as" -- please ignore this. this is the best way I know how to launch a system filepicker)
exporting sprites
- press "Save gfx..". choose a filename; the default is
/ram/cart/gfx/0.gfx
(which is the default spritesheet for your current cart) - IMPORTANT: if the spritesheet was already open in picotron's gfx editor, you'll need to close the file and reopen it (right click on the tab, close, then press the plus)
- if you saved to
/ram/cart/...
save your cart afterwards (ctrl-s)
exporting map
- (same as exporting sprites, just click "Save map.." instead)
- for an easy transition from pico8 maps to picotron maps, check out this snippet, which includes
mget
andmset
replacements
other ways to import (copypaste, aseprite)
future plans
changelog
hope, there's an update plan to implement import from .png spritesheet or something like that as a terminal command (like it was on pico-8)
You did good work there! :)
very useful, thank you!
Is it possible to import maps from pico-8? Not with this tool, but with some copy and paste? In pico-8 sprite editor we can copy data and paste it elsewhere, but it looks for the map editor you can copy, but it's only internally to pico-8, you can't paste it elsewhere.
We looked at this cart today on the stream. Based on the userdata trick we created a function to extract the GFX data directly from a P8 file
https://www.twitch.tv/videos/2093783120
-- load the file local myFile = fetch("myfile.p8") -- find the and extract gfx section local gfxstart, gfxend = string.find(myFile, "__gfx__") local mapstart, mapend = string.find(myFile, "__map__") local gfx = myFile:sub(gfxend+2, mapstart-2) -- remove the linebreaks gfx = string.gsub(gfx, "\n", "") -- convert into userdata local myspritesheet = userdata("[".."gfx]8080"..gfx.."[/gfx]") -- check if it worked if not myspritesheet then notify(string.format("* error: No valid gfx data")) return end -- this is how you draw it spr(myspritesheet,0,0) |
(had to add a superfluous .. in the userdata line so the BBS would't try to draw the GFX)
This also might not quite work right if you don't have a map. But it could be a good starting point for a more general Pico-8 importer
@farvardin I've added map importing!
@Krystman -- ooh that's a great idea!! I've incorporated it into the main cart
nice !
I noticed that picotron's spr function doesn't work well with your importer when you draw large sprites, like 2x2
I havent tested your map importer yet, but I also had the issue that standard picotron map draw 16x16 sprites even if the gfx has an 8x8 grid, so it doesn't work well either
so here is a little snippet I made to replace function spr and map so they work like pico 8, you just drop that at the start of your picotron lua file
map doesn't handle flag layers yet, but it should be possible to add
I'm sure at some point someone will make a lua file you can include so your pico 8 game more or less works instantly, like importing the .p8 as gfx and map as Krystman showed, and even the lua code, that will be so great!
_old_spr=spr function spr(_s,_x,_y,_w,_h,_mx,_my) _w=_w or 1 _h=_h or 1 for i=0,_w-1 do local _i=_mx and _w-i-1 or i for j=0,_h-1 do local _j=_my and _h-j-1 or j --_old_spr(_s+_i+_j*16,_x+i*8,_y+j*8,1,1,_mx,_my) _old_spr(_s+_i+_j*16,_x+i*8,_y+j*8,_mx,_my) end end end local _map_data=fetch("map/0.map") function mget(x,y) if not _map_data or not _map_data[1] then return 0 end return _map_data[1].bmp:get(x,y) end _old_map=map function map(_cx,_cy,_x,_y,_w,_h,...) for i=0,_w-1 do for j=0,_h-1 do local id=mget(_cx+i,_cy+j) if id!=0 then spr(id,_x+i*8,_y+j*8) end end end end |
[Please log in to post a comment]