nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
5k stars 483 forks source link

Autosave function #221

Open darkhog opened 7 years ago

darkhog commented 7 years ago

I'd like to be able to set an autosave for your game to prevent loss of data due to power outage or simply forgeting to save before exiting. Just add this to the config:

autosave = x, where x is amount of minutes between each autosave (0 to turn it off) Also this:

autosaveonexit=true- will autosave when TIC closes.

The autosave would fail silently if game wasn't saved at least once (new file) or if it can't be saved for another reason (read-only file or loaded from the site)

trelemar commented 7 years ago

I don't like this idea. Often I don't save a game while experimenting with different ideas, and when I want to start over, I just reload the game.

Also, if you mess your code up and want to reload the cart, what happens when the system autosaves just before you reload the cart? You completely lose data.

darkhog commented 7 years ago

Then you'd just disable autosave by setting period to 0 and setting autosave on exit to false. Simplebas that.

trelemar commented 7 years ago

I feel like it'd just cause more frustration. If you forget to save, it's your fault. If TIC saves for you when you don't want, it's TIC's fault. Just remember to save progress.

There's not much that can be done about power outages, these things happen.

darkhog commented 7 years ago

Well, it should be an option, just like autosave in Word is.

HomineLudens commented 7 years ago

I'm not a big fun of autosave functionality too, but I understand someone could like it. Maybe have a .bkp file saved in the same folder of the original one. Most of all I'd like to have some prompt for saving on exit. That happened a few times... lots of imprecations :)

trelemar commented 7 years ago

If TIC-80 stored a backup of the file at a set interval, without overriding the actual cart, I'm all for that. It could be stored in backup folder in tics appdata as the cart name + current os time or something similar. That I wouldn't mind. Just don't auto override the actual cart.

darkhog commented 7 years ago

Then it wouldn't be an autoSAVE now, would it? Again, having option to enable autosave doesn't mean you have to use it. Just like you don't have to be a redstone expert to play Minecraft.

msx80 commented 6 years ago

i'd like some autosave feature too. Possibly a backup save. Like, every tot minutes save a file like "autosave.tic" in some folder, so if your pc hangs for any reason, you never lose more than a tot minutes of work (which is incidently what just happened to me, lost 2 hours of work)

tobi commented 4 years ago

Since kids are really not used to manual saving anymore ( i know, learning opportunity... ) I think keeping an autosave.tic in a backup folder would be a big boon to Tic80

nesbox commented 3 years ago

Lets autosave in a backup.

Kyuchumimo commented 3 years ago

You could implement that the game is saved with checkpoints within the game (when entering a new screen or level, or a certain point of the game), that counts as an autosave, only that would be your responsibility to place those checkpoints.

skz1024 commented 3 years ago

You can implement in-game autosave by calling pmem() every time interval. (It's not perfect, because the user stores it as an integer.) However, if the program itself requires the concept of a backup file, the program's autosave feature is great.