Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Generic GameState that saves into JSON (or similar) #80

Open
Maaack opened this issue May 10, 2024 · 2 comments
Open

Suggestion: Generic GameState that saves into JSON (or similar) #80

Maaack opened this issue May 10, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Maaack
Copy link
Owner

Maaack commented May 10, 2024

Currently, the GameLevelLog tracks progress in the config file. This does not follow convention on where that data would typically be stored, as it mixes application configuration settings with game state.

Instead, we could try creating a generic GameState (or even more generic AppState) that stores a dictionary of data and manages the saving/loading behind the scenes. There's a lot of documentation available on how to save and load game state to and from files.

https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html

Eventually, it could have multiple levels, like UserGameState, PCGameState, WorldGameState depending on the level of persistence desired.

GameLevelLog, GameLog, AppLog could then be updated to read from the GameState instead of Config.

@Maaack Maaack added the enhancement New feature or request label May 10, 2024
@Maaack
Copy link
Owner Author

Maaack commented Jun 20, 2024

I think adding this could really help avoid devs (specifically, me) from getting into a bad practice of saving game state data in the config file instead, just because it is available.

@Maaack
Copy link
Owner Author

Maaack commented Aug 24, 2024

I have a working system from my last game jam that saves state into a Resource object, and then saves with ResourceSaver. It was simple and worked great for the jam, and may be better than trying to use JSON. There is a vulnerability that the resource files can hold executable code, but I'm not sure how that is a concern here. ( https://forum.godotengine.org/t/how-to-load-and-save-things-with-godot-a-complete-tutorial-about-serialization/44515#but-i-heard-from-someone-that-resources-are-insecure-13 )

I began porting it over, but stalled when trying to generalize it for the template. I'll try again in the near future.

@Maaack Maaack self-assigned this Aug 24, 2024
@Maaack Maaack pinned this issue Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant