I'm working on a Minecraft (2d) clone. I have world generation pretty much complete, but I need to have a way to store said generation. I know that using
printh() lets you write to files, but I want to read the contents from an external file like
new_world.dat or something similar.
You can use serial streams:
pico8 -run cart.p8 -i path/to/data pico8 -run cart.p8 < path/to/data
Create this cart in PICO-8 and save it as
cls() repeat size = serial(0x804,0x4300,0x1000) for i=0,size do print(chr(peek(0x4300+i)).."\0") end until(size == 0)
In a text editor, create a file named
the limerick packs laughs anatomical into space that is quite economical. but the good ones i've seen so seldom are clean and the clean ones so seldom are comical.
Start PICO-8 from the host operating system's command line, running
mycart.p8 and pouring in
limerick.txt as standard input:
pico8 < limerick.txt -run mycart.p8
As mentioned, this only works from the developer kit, and is not available in an exported cart or a cart uploaded to the BBS.
I rewrote the wiki page on serial(). Someone check my work, I made a couple of guesses.
@dddaaannn that looks like it'll work, but quick question, does the term 'exported cart' include ones that are exported as an application or just the web files?
It includes exported binaries as well as exported web. The file and stream access is not really intended for games, they’re more for tools. Drag and drop works in exported versions, with size limits, though that’s only an input, not an output.
In general, PICO-8 games aren’t able to persist large quantities of data to disk as part of gameplay. I only described the serial() example to elaborate merwok’s mention. If you’re willing to limit your game to being playable only in the “dev kit” PICO-8 app, you might be able to use some of these features.
[Please log in to post a comment]