Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • solarus solarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 229
    • Issues 229
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 10
    • Merge requests 10
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Solarus Games
  • solarussolarus
  • Issues
  • #1281
Closed
Open
Created Oct 14, 2018 by Alex Gleason@alexgleasonContributor

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.

Edited Oct 14, 2018 by Alex Gleason
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking