feat: Add gamestate command for save/load functionality - #31
Conversation
Adds a new console command 'gamestate' that allows saving and loading game states during runs: - gamestate save <name> - Saves current game state to .jkr file - gamestate load <name> - Loads a saved game state - gamestate list - Lists all available save files Includes path handling for both profile directory and mod directory saves.
|
ai pr with no linked issue or feature request :( |
Yeah, the description for this PR was generated by AI but from hand-written code. I wasn't able to find CONTRIBUTING.md outlining the contribution steps. I've just PR a feature that I'm using on my fork. Feel free to close it without additional comment if it's not planned. |
|
Thanks for the PR. I'm not quite sure the use case for this over the x and z keybinds. I find I almost never used more than 3 keybinds personally. I guess the mod bundled states may be useful for testing stuff, but smods and other mods love breaking stuff with old saves, and the fact that the card's ability table is stored means if you adjust any values your save is just invalid. If you are wanting a system to reliably make game states to make sure things work well, https://github.com/BakersDozenBagels/Balatest/ is probably what you're looking for. |
Summary
Adds a new
gamestateconsole command that provides convenient save state management during gameplay. This allows players to save snapshots of their run at any point and load them back later, which is invaluable for debugging, testing specific scenarios, and experimenting with game mechanics.Motivation
When debugging or developing mods, it's often necessary to test specific game states repeatedly. Previously, this required either:
.jkrsave files in the file systemThis feature streamlines the workflow by providing an in-game interface for save state management.
Usage
Save a Game State
Saves the current game state to
<name>.jkrin your profile directory.Example:
Restrictions:
Load a Game State
Loads a previously saved game state from
<name>.jkr.Example:
Note: This will delete your current run and replace it with the loaded state.
List Available Game States
Displays all available
.jkrfiles in your profile directory with their full paths.Example output:
Technical Details
Implementation
Core functions (
debugplus/core.lua):saveGameState(filename)- Uses Balatro's nativesave_run()andcompress_and_save()functionsloadGameState(filename)- Usesget_compressed()andG:start_run()to restore statelistGameStates()- Scans profile directory for.jkrfilesConsole command (
debugplus/console.lua):Path Handling
The implementation supports two path modes:
save1) - Stored in profile directoryMods/MyMod/fixtures/test) - Allows mods to bundle test fixturesFile Format
Uses Balatro's native
.jkrformat (compressed save files), ensuring full compatibility with:Testing
To test this feature:
/)gamestate save test1gamestate load test1gamestate listNotes