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!

P#142713 2024-03-10 06:40 ( Edited 2024-03-10 06:42)

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.

P#142714 2024-03-10 07:27
1

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

P#142924 2024-03-14 17:07

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

P#142925 2024-03-14 18:02

[Please log in to post a comment]