Log In  


i know i can possibly write to a file with printh how can i read from a file then?

1


You can't read from files in a general sense. There's no general IO library.

It depends on what are you trying to accomplish, though. If you're trying to save data, look into cartdata(). If you want to "flash" the cartridge, look at cstore().

But there's nothing that's the "opposite" of using printh(), which is really meant as a logging utility.


Judging from this and your other thread on keyboard/mouse input, it seems you may be conceiving of PICO-8 as a general purpose computer, when in fact it is really much more of a console (with a gamepad as input) for which you happen to have the editing tools to produce cartridges for end-users. Keeping this in mind may clarify some things for you.

Also, please remember to check the category when posting, as this is your second post in the "Cartridges" category which is not a cartridge. This should be in "Discussion" or "Workshop" or something. Thanks.


im just looking for a way to save the game


1

If you're feelin' mad there's a couple things you could try. This form talks about using the GPIO pins to communicate with the outside world from a pico 8 card. The github repo is still live so you could figure out how they did it and try something similar.
https://www.lexaloffle.com/bbs/?tid=30059

This thread talks about shoving data into the pico 8 ram on the fly, which, I mean, I guess, if they did it, must be possible. Though they don't have any code to show how, maybe it's the start of a investigation.
https://www.lexaloffle.com/bbs/?tid=2718

I sware there was another networking game using pico 8 and some javascript to pass information between (and therefore into) carts but I can't find it right now. If you search around on google you may find other examples.

But yeah as kittenm4ster says the Pico 8 is a games console, not a computer. So that's worth bearing in mind when dreaming up Pico 8 projects.

EDIT: I only saw the comment re- just wanting save data after writing this - I think it was posted while I was writing this.


Oh, for saving the game check out the Persistent cart data section of memory and start from there.
http://pico-8.wikia.com/wiki/Memory

You want to use cart data:
http://pico-8.wikia.com/wiki/Cartdata

You don't save to a seperate file you write to the cart itself hence why we were confused! (I've not tried it though!)


Yeah, if you want to save some state to the cart, look into cartdata() like Davbo said now (and like I said earlier). But if you want to save the actual game you are writing, then: http://pico-8.wikia.com/wiki/Save



[Please log in to post a comment]