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!
@dev-worm11 ай бұрын
youre right, thanks for reminding me! glad it was able to help!
@tiagogarcia490011 ай бұрын
Hmmm I'll be saving this for later
@Memose211 ай бұрын
Best comment I read so far
@MdTahsinMazhar-qr7uw6 ай бұрын
Seriously, you'll be "saving" 😅
@Elvendertig113028 күн бұрын
Ba Dum Tss!
@4U4U79 ай бұрын
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.
@dev-worm9 ай бұрын
so glad to hear!! thank you so much!
@lucasmence11 ай бұрын
I don't use godot yet, but I love to watch your videos about game dev, keep it up! Cheers!
@dev-worm11 ай бұрын
I appreciate that!
@leandroverse10 ай бұрын
Why changing the resource in every frame? Couldn't it be changed when saving, like calling UpdatePos inside save() before ResourcerSaver?
@alli-gator-forest10 ай бұрын
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.
@dev-worm10 ай бұрын
ah yes!! thanks for pointing that out!!
@Lupin_VA10 ай бұрын
mine spontaneously stopped working and this fixed it thank you
@SollyVlogs11 ай бұрын
Thank you for the tutorial, super helpful :) !
@dev-worm11 ай бұрын
so happy to hear
@reesekelly238811 ай бұрын
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.
@reesekelly238810 ай бұрын
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!
@cheapgrams295511 ай бұрын
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!
@thesomeone2nd11 ай бұрын
He already has 2 videos for that go check them out.
@dev-worm11 ай бұрын
Just uploaded a really simple and for sure easily replicable 2 part tutorial series not long ago, I hope that is able to help
@cheapgrams295511 ай бұрын
Ah yes I see, excuse my ignorance. Just excited to learn I guess lol shoulda looked deeper!
@debunkler7 ай бұрын
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.
@azumashinobi15593 ай бұрын
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.
@Coz3erz3 ай бұрын
@@azumashinobi1559Large games require wayyy more vars and stuff , tons of one off variables , node specific vars , temp vars , all very hard to keep track of. In somethin like gamemaker u would use structs which was very useful. But I think we may be able to use dictionaries to store data.
@therealcherrypapa6 ай бұрын
You saved me a lot of time.
@dev-worm6 ай бұрын
so happy to hear!!
@MultiLeandrini11 ай бұрын
This exactly what I wanted/needed/was looking for. What is this timing? thanks
@HippocritterXD11 ай бұрын
this is a great video thanks for making it. i was wondering are you gonna continue with the survival game series?
@dev-worm11 ай бұрын
any ideas for what could be next??
@gamer20_11 ай бұрын
maybe add this saving and loading @@dev-worm
@HippocritterXD11 ай бұрын
@@dev-worm maybe a boss with a few mechanics
@HippocritterXD11 ай бұрын
@@dev-worm or a level up system
@Kirbo-The-Dirbo11 ай бұрын
I needed this so bad. Thanks
@strike53825 ай бұрын
this really helped me with understanding this, thanks
@dev-worm5 ай бұрын
so glad to hear that!! if you need help with anything just let me know!!
@HGamesStudio-cs9dh2 ай бұрын
Can you do a video on how to save a whole scene tree so I can save instantiated scenes and their animation instead of just saving vars??
@PerfectUbaid11 ай бұрын
Hi man very interesting video
@adrianvazquez868611 ай бұрын
Hey!! Would you make a tutorial on how to make a good menu and UI?? It'll be really helpful!!
@dev-worm11 ай бұрын
working on one now!!!
@adrianvazquez868611 ай бұрын
@@dev-worm thx man!!
@WunderChilld11 ай бұрын
Thanks for the videos brother, could you bring a video explaining how to enter/use some type of vehicle? whether horse, car, etc.
@jasonwilliams873011 ай бұрын
Epic tuts!
@MrStarlightt11 ай бұрын
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?
@dev-worm11 ай бұрын
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
@xmacherie5 ай бұрын
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!
@CCLawhon2 ай бұрын
I was thinking of this same thing with the map! This could load the scene path -> player position in the scene. I don't think you want to load the scene from here though (see others' comments). This is for the player. And I don't know how scenes as resources would benefit much. Here, though, I think that if the player position is saved, it's saved in relation to that scene (ironically, though, globally lol), and as such, if you were sure the scene loaded first before the player position, it should work? I think the Map data could be saved "at its position" in a similar way, and I'm assuming Map/Player are in some sort of "area" which is a scene...in which case all those things could work with his system. But, someone mentioned a lot of "nodes" and that's separate from the data (the way I understand it) for a good reason. So to organize, save, and load the *data* for the player, another for enemy, map, NPCs, whatever, I think this is streamlined. The data for the player is on the player, not in a global or level or scene node cluttering, taking up space, and it allows one line call like global, when you need it. I personally, in 3D open world or rpg type stuff, prefer using the Godot Node for player position, which can be saved/loaded with the rest of the nodes-and that keeps it in the scene. You can update them at certain times or a lot less than every frame. Plus, the player position nodes can be placed at spawn points if players just need to spawn back in a general area. Another thought: someone else commented, calling this every frame is a lot if you're only using it once when leaving the game. Which is probably why big games use checkpoints and other methods. But if your game got cut off (like your brother pulled the plug out of the wall, say), you'd at least have the player pretty darn close to where it was before the "incident." Not as big of a deal with rpg maybe, but platform or car racing or something it might really matter as position is everything. As for security, again, here you're saving player data...not the player code, not game mechanics, not anything other than the stuff that changes in the game (like position or xp or health) that you literally see in the UI in the game, and I don't really understand why that would need to have "heightened security." As for scaling this idea, I think he is saying, the player data is saved as a resource to the player (player data not cluttering up the rest of the nodes), and that is good. A small text doc does not cost much to save often. Since you aren't putting actual nodes, etc in it, it seems like a solid plan? I would love someone to argue this with me, because I'm not 100% sure I really understand resources' unique qualities.
@zerolol29Ай бұрын
Hello, sorry for bothering but I don't know why I get this error: Parser Error: Class "PlayerData" hides a global script class.
@eason93 күн бұрын
You might have another script with the class name "PlayerData". Check if you had accidentally duplicated the PlayerData sript and delete the duplicated one.
@ROSACEPONY10 ай бұрын
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.
@CCLawhon2 ай бұрын
there is a solid tut for char selection screen...not fancy but allows for classes, etc. Google Character Selection Screen Godot 4. GoGameDev is the person who did it. I can't imagine what else we'd need if we have that?
@wellplayedggwp29511 ай бұрын
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?
@dev-worm11 ай бұрын
export each item and when changing the var make sure to do so in the external resource file
@i_draw_whatever186 ай бұрын
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.
@dev-worm6 ай бұрын
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.
@Manimanocas6 ай бұрын
Im sorry for commenting but do you think this is a good way of storing health, acquired skills etc across scenes?
@uiet652710 ай бұрын
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
@GameLog010 ай бұрын
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?
@Lupin_VA10 ай бұрын
thats what im trying to figure out i accidentally put my player in a void ;-;
@CCLawhon2 ай бұрын
@@Lupin_VA did you figure it out? I'd guess you could make a reset function that sets each player data variable back to its original state on input key or on a button somewhere? Maybe it doesn't reset the score/player name/choices they made about stuff, but sets them back to spawn point and health to 100, etc?
@Lupin_VA2 ай бұрын
@CCLawhon try deleting the actual save file
@Lupin_VA2 ай бұрын
I dont remember exactly what i did as this was forever ago and i dont have the project anymore
@CCLawhon2 ай бұрын
@@Lupin_VA I got it! func _on_reset_button_pressed() -> void: var save_file_name = "savegame.json" var save_path = "user://" + save_file_name # Create default player data var default_data: Dictionary = { "gamertag": "", "honorific": "", "heritage": "", "talisman": "", "xp_ingame": 0, } # Write the default data to the save file var file = FileAccess.open(save_path, FileAccess.WRITE) if file: file.store_string(JSON.stringify(default_data)) file.close() print("Save file reset to default values. Starting fresh!") # Reset in-game values explicitly GlobalData.xp_ingame = 0 GlobalData.xp_combined = GlobalData.xp # Update the display to reflect the reset update_xpbar() label_xp.text = str(GlobalData.xp_combined) else: print("Failed to open save file for resetting.") # Reload the scene to refresh with default data get_tree().reload_current_scene()
@CAlexRPG7 ай бұрын
I'm getting a "cannot call method 'duplicate' on a null value, not sure what to do, it saves fine, just doesn't load
@CAlexRPG7 ай бұрын
Nevermind, I forgot to make the save file .tres
@fulla111 ай бұрын
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?
@dev-worm11 ай бұрын
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
@uiet652710 ай бұрын
In future video can you make this video for clear explanation for beginners like me
@dev-worm10 ай бұрын
what arnt you understanding? maybe I could clear it up for you!
@Whhatt11 ай бұрын
Can you please make a tutorial on deceleration on a 2d platformer Good vid btw
@dev-worm11 ай бұрын
working on it!!
@asd1-so5sl8 ай бұрын
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.
@rayoxp3 ай бұрын
"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."
@HoberMallow-tg3ph8 ай бұрын
Can you explain using .duplicate(true)?
@CCLawhon2 ай бұрын
I found this in docs for Array today! True means "deep duplicate" which means it doesn't overwrite your original template. That way you save the original template, duplicate it, and overwrite that copied one. If duplicate is used without true (or set to false) it makes it an exact mirroring copy that changes the original when you change it! I bet it works the same here!
@planktime11 ай бұрын
HELLO!
@dev-worm11 ай бұрын
HELLO!
@planktime11 ай бұрын
@@dev-worm Thanks for coming through on that.... My GF is now saying hello the same way.
@F_Du_Sea10 ай бұрын
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.
@domaa_h7 ай бұрын
TYSM
@dev-worm7 ай бұрын
glad it helped!!
@Sammo_Wammo_Real2 ай бұрын
Hey, just be careful when using the resource for saving, because people can modify their save file to be malicious, and delete Sys32, or download malware to your system.
@dev-worm2 ай бұрын
ahh you are very right, I had no idea about that until just recently!! thanks for sharing that, so others can be aware of it!
@CCLawhon2 ай бұрын
How would you avoid that?? What else would you use for saving data?
@Sammo_Wammo_Real2 ай бұрын
@@CCLawhon I think GDQuest made a video on avoiding this problem. Check it out!
@tonnypedersen591511 ай бұрын
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.
@GooseBibleTunes9 ай бұрын
🤓
@ElectrocubeOfficial5 ай бұрын
🤓
@jeremiahaemile200811 ай бұрын
thanks man i will watch it in my a vaction and ya i am jeremiah but i change my profile picture