-1
\$\begingroup\$

using this tutorial, my game crashes before opening and gives 0 errors... doesn't even tell me what's wrong.

All the code I'm using is literally just this open project: https://github.com/BirdyBirdBirbs/picokun copied and pasted. which is the same exact thing you see in the video... but for my game engine version, because the main one got updated to 4.0

In the save function I obviously changed what the save system is supposed to save to account for compatibility.

so:

func load(save_game: Resource):
var data: Dictionary = save_game.data[SAVE_KEY]
stats.health = data['health']
stats.energy = data['energy']
stats.maxhealth = data['maxhealth']
stats.maxenergy = data['maxenergy'] 

which is literally the same thing but using my variable names instead of theirs, like they use max_health... and mana I use maxhealth and energy...

I've been spending days searching for tutorials on godot on how to make saving system and the internet is polluted with either useless "quick" 2-5 minute tutorials or with templates that don't explain anything at all about how the node system works, pretty much all of the methods I tried just give me crashes .

and the godot documentation assumes that I have a college degree in rocket science.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ For starters: to store persistent data files, like the player's save or settings, you want to use user:// instead of res:// as your path's prefix. More on that here. \$\endgroup\$
    – Pikalek
    Commented Jul 1, 2023 at 22:13
  • \$\begingroup\$ Also, if you check your project, there should be a 'logs' (or maybe 'log') folder in there somewhere which likely has info about the the crash. \$\endgroup\$
    – Pikalek
    Commented Jul 1, 2023 at 22:17
  • 1
    \$\begingroup\$ Do these help: gamedev.stackexchange.com/a/205270/10408 and stackoverflow.com/a/76280712/402022? \$\endgroup\$
    – Theraot
    Commented Jul 1, 2023 at 23:03

1 Answer 1

1
\$\begingroup\$

This is nearly impossible to debug – only guess – given your small code snippet above. If the debug console doesn't include any errors, this sounds as if your actual code flow cause the engine to exit.

Either way, to me this feels as if you're overcomplicating things unnecessarily.

I no longer have version 3 installed, so this is from memory, but all you actually should have to do:

Godot's built-in class ConfigFile already has all the neat little tricks you're looking for in a savegame/savestate.

To use this, it should be enough to just create your own global autoload/singleton class (there should be tons of tutorials on how to enable this):

SaveState.gd

extends ConfigFile

This is all. Just this one line (while you can add extra functionality, if you need it, for example some checksum calculation). Register it under the global name SaveState (Project Settings > Autoloads) and your objects may use it like this:

Player.gd

func _ready():
  # Load maximum health, use the current/default value as the default
  self.max_health = SaveGame.get_value('player', 'max_health', self.max_health)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .