Skip to content

Game.gd rewrites the tracked file _userFiles/game_01.tscn on every run #118

Open

Description

@ccady

Game._ready() in the MVP game (Phase2/MVP/Game/bcirpg_game_mvp_2024_0831A/gamePlay/Game.gd) calls save_module() every time the game scene starts:

#DKM TEMP: saves the entire scene in one packed scene file
func save_module():
		var scene = PackedScene.new()
		scene.pack(self)
		#var _saveResponse = ResourceSaver.save("user://game_01.tscn", scene)
		var _saveResponse = ResourceSaver.save("res://_userFiles/game_01.tscn", scene)

Problems

  1. Every run edits a tracked file. _userFiles/game_01.tscn is in the repo, so running the game leaves it modified in git status. It has been committed many times, and it nearly slipped into Fix ObjectDB instances leaked at exit in the MVP game #117.
  2. The saved file isn't used. Nothing in the project loads game_01.tscn. pack() only saves nodes owned by the scene, and the call happens at the start of _ready(), before any game text or options exist. The output is essentially a copy of Game.tscn.
  3. It fails in exported builds. res:// is read-only in exported builds, including HTML5. The return value is ignored, so the save fails silently.

History

save_module() was added in 60b8f78 (April 2022) with the comment #DKM TEMP: for testing only. It replaced an earlier load_module() experiment, and it saved to user://game_01.tscn, which is outside the repo. It was later changed to save to res://_userFiles/.

Possible fixes

  • Remove the save_module() call (and the function), and delete _userFiles/game_01.tscn from the repo. Or:
  • If it's still wanted for debugging, save to user:// again, and delete or ignore the tracked copy.

MacDugRPG, is this still needed for anything planned, such as saving and reloading a game state?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions