Log In  


Hi all, just getting started with saving player data.

cartdata() returns true or false depending on if there was existing cartdata or if it was just created. I am testing initialization of some default cartdata in the case that it returns false but I am having trouble testing this more than once per cartdata ID / per cart. I have tried wiping out 0x5e00-0x5eff with memset(0x5e00,0,0xff) but it doesn't seem to reset the boolean representing the presence of existing cartdata (unless I'm doing this wrong). Does anyone know if there is a way to fully delete/reset cartdata for a given cart/cart ID?

Thanks!



1

cartdata return value just tells you if data was loaded. You don't get the reason when it returns false. (new save, invalid name, cartdata has previously been called...)
Depending on how much of the 256 bytes you need, having a single value (bit/byte/pico dest number) that you set to 1 once you've done the unique first initialization seems more reliable.
This way your memset is perfectly valid to wipe the save, as would be to set the flag to 0. I don't know a way to programatically delete the save so the cartdata call returns false again.


1

I would assume finding the file cartdata creates and deleting it also works? It will have the name you defined when calling cartdata


Ah yes, thank you @Doriencey, I did not realize they are stored in a different directory but there they are in .lexaloffle/pico-8/cdata

Thanks to @RealShadowCaster as well for the clarification


This one line should be enough to determine if the saves are initialized to 0.

count({peek(0x5e00,256)},0)==256

https://www.lexaloffle.com/bbs/?tid=144715

If we could delete cartdata files using code alone, a malicious cart could appear that would erase our favorite cartdata files.



[Please log in to post a comment]