I came across your older save and load tutorial through the algorithm, then decided to look at your channel and saw you uploaded this 4 days ago! I recommend adding a pinned comment to your older tutorial linking to this one! Great job, and thank you!
Hi DevWorm! Just want to thank you so much, I have had troubles saving persistent data and just could not get it to work but I have solved it with your help! Keep well and keep up the good work.
Cool guide for small games! But somewhat falls apart at scale. You'd need to create a centralized save/load structure with an inheritance paradigm instead of this coupled strategy. Also, saving directly as a .tres leaves the save file really vulnerable to security risks (injecting code, changing values). You can use Safe Resource Loader from the asset library to load a Resource more securely.
If you don't mind could you explain why this wouldn't work with large scale games? I'm working on a project that I think is small enough but I wanna be sure.
Thank you for this amazing video! Personally, I wanted to load my Resource using the _ready() function, so I changed the load_data() function to add the following if statement: if ( ResourceLoader.exists( save_file_path + save_file_name ) ): playerData = ResourceLoader.load( save_file_path + save_file_name ): This ensures it won't try to load a file that doesn't exist on the very first time running the line of code, allowing you to call the load function before you make a save.
Great video. I really like the idea of using resources to save however there are a lot of people who are saying that if a player downloads files for your game it can breach their security. Is there a work-around for this? I also want to implement multiple saving slots so maybe I should just use JSON... even though it's a lot less intuitive.
Update: I got everything to work using JSON except the player inventory which is a resource. I think I am going to have to revert to the version of my game I had a month ago and implement a resource system instead of JSON. I have tried so many different methods. I would love to see @DevWorm's solution to saving an inventory because my inventory system is pretty similar to the one in his other video. It would help greatly Thanks!
Thank you so much for this tutorial, it was very simple and easy to understand. I have a question - if I want to add some additional parameters to the save file, such as on a RPG with a map with changes in scenes, I would just theoretically save the scene path that the player is in and load that scene path? I want to make it an open exploring game and keep track of where the player is on the map, quest status, item spawn status, etc. and feels like it could get pretty confusing pretty fast. Thank you!
What if instead of pressing a button to save we want to save the progress we’ve made in one scene before changing to the next one? Like say you collected coins from scene 1, then you go to scene 2 to collect more before going back to scene 1, only to see the coins you had collected are back at their place again.
then you would have to save them in different files!! so for instance have a scene1 data file and a scene2 data file. and load those files in and out when the scene is switch to and from.
Hey Dev! Since I’m early I want to use my newfound comment powers to request an inventory system!! I feel like you could explain one in a simple and replicable way! Much love and thank you for the dope tutorials!
so does this save the game when i close the game, like will the player be in the saved position next time i open the game or is this a save system for a running game only?
What if I want to change the translated language? I've already done it so that when you click the buttons, the language of the game changes, but I want to save it. So when I reopen the game, if i had set the game to french, it opens in french. If I change it again to English, close it, and open it again, it should be in English. While I understand that it has the same method, I don't understand the coding part of it. I need a youtube tutorial on it please. can't find one.
Can you make a tutorial on how to make a character selection screen that also include a character creator and being able to save our character in a slot/list? (this definitely not for my game i swear😁) On a serious note, it could benefits a ton of gamedev as it's very common in RPG to have a character creator+selection screen.
I make resource of each collebtible items and export them to external resource file, and There is dynamic var inside resource which is amount(default is 0), but whenever i tried to make changes and load it, its always reset to its default var, is it Only saving the reference? Or I should not export each item and define them inside the code instead?
I'm making a 2d game using your all tutorials but I'm stuck with save and auto load when i exit and enter the game and i can't understand how the save and autoload works ! Can you make a simple auto save and load video for simple game please
This resource file is only temporary, right? I mean if you restart the game it will always start with the same location and health. In other words: is this adaptable to have e.g. EXP, current level, ... saved permantently and load it on the next start of the game?
no its not temporary, it saves into that folder and file we created as variables. so if you close the game and come back then it will keep the saved data
Is there no easier way to do this? This seems really convoluted, and the tutorial itself doesn't help either. You have functions change_heath and UpdatePos (I'd stick to one naming convention, by the way) which have nothing to do with actually loading and saving. My point is that the code you write should be portable. Anyways, isn't there a way to do something like this?: # World Data with open("saves/save.json") as saveFile: data = json.load(saveFile) # Use Case if keys[pygame.K_e]: for chest in data["chests"]: if data["player"]["x"] == chest["x"] and data["player"]["y"] == chest["y"]: chest["open"] = True # Another Use Case xCamera = data["player"]["x"] - (xMax // tileSize) // 2 yCamera = data["player"]["y"] - (yMax // tileSize) // 2 In this code, the loading & saving are clearly displayed, and there is a use case. In this tutorial I can barley tell the two apart. Another criticism I have is the length of the video. There is absolutely no way you need 20 minutes to explain a concept as easy as literally opening a file, then reading & writing from it. You made a tutorial on how to make your game, not how to save and load files.
using resource files for save game system is a bad idea, they are not safe for use in user land, they are perfect for actual resources in the game and nothing else, for save game use a text based system or a actual database like SQLite or similar, it is also a good idea to encrypt the save file to prevent cheating.
I came across your older save and load tutorial through the algorithm, then decided to look at your channel and saw you uploaded this 4 days ago! I recommend adding a pinned comment to your older tutorial linking to this one! Great job, and thank you!
youre right, thanks for reminding me! glad it was able to help!
Hmmm I'll be saving this for later
Best comment I read so far
Seriously, you'll be "saving" 😅
Hi DevWorm! Just want to thank you so much, I have had troubles saving persistent data and just could not get it to work but I have solved it with your help! Keep well and keep up the good work.
so glad to hear!! thank you so much!
I don't use godot yet, but I love to watch your videos about game dev, keep it up! Cheers!
I appreciate that!
Why changing the resource in every frame? Couldn't it be changed when saving, like calling UpdatePos inside save() before ResourcerSaver?
Cool guide for small games! But somewhat falls apart at scale.
You'd need to create a centralized save/load structure with an inheritance paradigm instead of this coupled strategy.
Also, saving directly as a .tres leaves the save file really vulnerable to security risks (injecting code, changing values). You can use Safe Resource Loader from the asset library to load a Resource more securely.
If you don't mind could you explain why this wouldn't work with large scale games? I'm working on a project that I think is small enough but I wanna be sure.
Thank you for the tutorial, super helpful :) !
so happy to hear
Thank you for this amazing video!
Personally, I wanted to load my Resource using the _ready() function, so I changed the load_data() function to add the following if statement:
if ( ResourceLoader.exists( save_file_path + save_file_name ) ):
playerData = ResourceLoader.load( save_file_path + save_file_name ):
This ensures it won't try to load a file that doesn't exist on the very first time running the line of code, allowing you to call the load function before you make a save.
ah yes!! thanks for pointing that out!!
mine spontaneously stopped working and this fixed it thank you
You saved me a lot of time.
so happy to hear!!
this really helped me with understanding this, thanks
so glad to hear that!! if you need help with anything just let me know!!
Great video. I really like the idea of using resources to save however there are a lot of people who are saying that if a player downloads files for your game it can breach their security. Is there a work-around for this? I also want to implement multiple saving slots so maybe I should just use JSON... even though it's a lot less intuitive.
Update: I got everything to work using JSON except the player inventory which is a resource. I think I am going to have to revert to the version of my game I had a month ago and implement a resource system instead of JSON. I have tried so many different methods. I would love to see @DevWorm's solution to saving an inventory because my inventory system is pretty similar to the one in his other video. It would help greatly Thanks!
Thank you so much for this tutorial, it was very simple and easy to understand. I have a question - if I want to add some additional parameters to the save file, such as on a RPG with a map with changes in scenes, I would just theoretically save the scene path that the player is in and load that scene path?
I want to make it an open exploring game and keep track of where the player is on the map, quest status, item spawn status, etc. and feels like it could get pretty confusing pretty fast. Thank you!
What if instead of pressing a button to save we want to save the progress we’ve made in one scene before changing to the next one?
Like say you collected coins from scene 1, then you go to scene 2 to collect more before going back to scene 1, only to see the coins you had collected are back at their place again.
then you would have to save them in different files!! so for instance have a scene1 data file and a scene2 data file. and load those files in and out when the scene is switch to and from.
I needed this so bad. Thanks
This exactly what I wanted/needed/was looking for. What is this timing? thanks
Hi man very interesting video
Hey Dev! Since I’m early I want to use my newfound comment powers to request an inventory system!! I feel like you could explain one in a simple and replicable way! Much love and thank you for the dope tutorials!
He already has 2 videos for that go check them out.
Just uploaded a really simple and for sure easily replicable 2 part tutorial series not long ago, I hope that is able to help
Ah yes I see, excuse my ignorance. Just excited to learn I guess lol shoulda looked deeper!
Thanks for the videos brother, could you bring a video explaining how to enter/use some type of vehicle? whether horse, car, etc.
so does this save the game when i close the game, like will the player be in the saved position next time i open the game or is this a save system for a running game only?
yes if you save the data then close the game it will still keep that data saved for when you open the game back up
What if I want to change the translated language?
I've already done it so that when you click the buttons, the language of the game changes, but I want to save it.
So when I reopen the game, if i had set the game to french, it opens in french. If I change it again to English, close it, and open it again, it should be in English.
While I understand that it has the same method, I don't understand the coding part of it.
I need a youtube tutorial on it please. can't find one.
Can you make a tutorial on how to make a character selection screen that also include a character creator and being able to save our character in a slot/list? (this definitely not for my game i swear😁)
On a serious note, it could benefits a ton of gamedev as it's very common in RPG to have a character creator+selection screen.
Epic tuts!
Im sorry for commenting but do you think this is a good way of storing health, acquired skills etc across scenes?
this is a great video thanks for making it. i was wondering are you gonna continue with the survival game series?
any ideas for what could be next??
maybe add this saving and loading
@@dev-worm
@@dev-worm maybe a boss with a few mechanics
@@dev-worm or a level up system
Hey!! Would you make a tutorial on how to make a good menu and UI?? It'll be really helpful!!
working on one now!!!
@@dev-worm thx man!!
I make resource of each collebtible items and export them to external resource file, and There is dynamic var inside resource which is amount(default is 0), but whenever i tried to make changes and load it, its always reset to its default var, is it Only saving the reference? Or I should not export each item and define them inside the code instead?
export each item and when changing the var make sure to do so in the external resource file
I'm getting a "cannot call method 'duplicate' on a null value, not sure what to do, it saves fine, just doesn't load
Nevermind, I forgot to make the save file .tres
I am a bit confused. I was planning on using this as a guide for a save/load system, but how would I reset the save file if i want to start over?
thats what im trying to figure out i accidentally put my player in a void ;-;
I'm making a 2d game using your all tutorials but I'm stuck with save and auto load when i exit and enter the game and i can't understand how the save and autoload works !
Can you make a simple auto save and load video for simple game please
"I want to save the scene path when a player moves from one scene to another and save it in a JSON file in Godot 4."
This resource file is only temporary, right? I mean if you restart the game it will always start with the same location and health.
In other words: is this adaptable to have e.g. EXP, current level, ... saved permantently and load it on the next start of the game?
no its not temporary, it saves into that folder and file we created as variables. so if you close the game and come back then it will keep the saved data
Can you explain using .duplicate(true)?
In future video can you make this video for clear explanation for beginners like me
what arnt you understanding? maybe I could clear it up for you!
Can you please make a tutorial on deceleration on a 2d platformer
Good vid btw
working on it!!
Is there no easier way to do this? This seems really convoluted, and the tutorial itself doesn't help either. You have functions change_heath and UpdatePos (I'd stick to one naming convention, by the way) which have nothing to do with actually loading and saving. My point is that the code you write should be portable. Anyways, isn't there a way to do something like this?:
# World Data
with open("saves/save.json") as saveFile:
data = json.load(saveFile)
# Use Case
if keys[pygame.K_e]:
for chest in data["chests"]:
if data["player"]["x"] == chest["x"] and data["player"]["y"] == chest["y"]:
chest["open"] = True
# Another Use Case
xCamera = data["player"]["x"] - (xMax // tileSize) // 2
yCamera = data["player"]["y"] - (yMax // tileSize) // 2
In this code, the loading & saving are clearly displayed, and there is a use case. In this tutorial I can barley tell the two apart. Another criticism I have is the length of the video. There is absolutely no way you need 20 minutes to explain a concept as easy as literally opening a file, then reading & writing from it. You made a tutorial on how to make your game, not how to save and load files.
TYSM
glad it helped!!
HELLO!
HELLO!
@@dev-worm Thanks for coming through on that.... My GF is now saying hello the same way.
using resource files for save game system is a bad idea, they are not safe for use in user land, they are perfect for actual resources in the game and nothing else, for save game use a text based system or a actual database like SQLite or similar, it is also a good idea to encrypt the save file to prevent cheating.
🤓
🤓
thanks man
i will watch it in my a vaction
and ya i am jeremiah but i change my profile picture
thanks jeremiah so happy to see you brother!
MCSQUIRMY!!