Feature request: save a game into a specific file
(Not to be confused with #715 which asks the write directory to be configurable.)
My game has two options when you open it: New Game, Continue.
For "Continue", all is well. Thanks!
For "New Game", I want an empty game loaded into memory, but when it's saved I want to overwrite save1.dat.
I have tried a few ways with Lua scripting and I don't think it's really possible. The filename of the save is contained in a Savegame userdata object (inseparable from the save values themselves) attached to the game object.
This doesn't work:
if new_game then
game = sol.game.load("tmp_save")
function game:save()
game.filename = "save1.dat" -- not possible
getmetatable(game).save(game)
end
end
This could work, but is very tedious:
if new_game then
game = sol.game.load("save1.dat")
initial_game:reset_all_values(game) -- all possible save values are reset here
end
This does work, but it's brutal!
if new_game then:
sol.game.delete("save1.dat")
game = sol.game.load("save1.dat")
end
Anyone who accidentally clicks the "New Game" button will be very upset! The old file is immediately, irreversible destroyed. Maybe a warning ("are you SURE?") will improve it, but it's still not ideal. I'd rather warn the player right before the game would be overwritten.