Save And Load Data in Godot 3.2

Поділитися
Вставка
  • Опубліковано 24 кві 2020
  • Saving and loading data can be a daunting task if you've never done it before, but it's a lot easier than you might think. In this video I'll be showing you how you can save binary data onto your player's machine so that you can retrieve it later. This is useful for allowing your player to come back to their game without losing their progress. You can store many things such as player stats, levels completed, and even collectables they've gathered.
    Error Codes: docs.godotengine.org/en/3.2/c...
    Source: github.com/GameEndeavor/save-...
    Become a patron to get exclusive content and support the channel:
    / gameendeavor
    Join Our Community! We look forward to welcoming you.
    Discord: / discord
    Twitter: / gameendeavor
    Into: Splashing Around - The Green Orbs

КОМЕНТАРІ • 244

  • @GameEndeavor
    @GameEndeavor  4 роки тому +138

    Howdy everyone. A little disclaimer since I've gotten a few messages about this. The password at the end is NOT a legitimate password. The one frame reveal is on purpose and intended as a joke, so enjoy. :D I'm touched though, I didn't expect so many people to be concerned, but thank you kindly. Enjoy the video!

    • @Amipotsophspond
      @Amipotsophspond 4 роки тому +4

      thank you, "pb" for thinking about us explorer types and for telling us about the Easter egg in the video. looks like a really legitimate password for being a fake, I think that was why their was real concern.

    • @Wolfyxon
      @Wolfyxon 3 роки тому +3

      Howdy, its me flowey

    • @GameEndeavor
      @GameEndeavor  3 роки тому +3

      @@Wolfyxon Howdy, Flowey. :)

    • @Wolfyxon
      @Wolfyxon 3 роки тому

      @@GameEndeavor
      I think i too much played Undertale
      I turning to Flowey

    • @GameEndeavor
      @GameEndeavor  3 роки тому +3

      @@Wolfyxon Is that the flower? I still need to beat that game.

  • @benjwilliams5104
    @benjwilliams5104 4 роки тому +57

    Creating a save system has been something I've put off so long on my current project (which is my first real game, and my first project with a save system!) This tutorial was so straightforward, and I really appreciate that here, and in all of your videos, you go over not just the steps, but WHY we use them, and what they mean.
    I also love your sense of humor, charming and engaging without being overly zany and distracting.
    Anyway, all this to say, thank you for making videos! I'm a little less daunted by the prospect of writing a save system, now :)

    • @GameEndeavor
      @GameEndeavor  4 роки тому +13

      This is genuinely the nicest comment I've ever received, thank you very much. It means a lot to me. :) You pretty much captured the concept of this channel in one comment. All of that is intentional, because it's what I would like to see more of. Especially the why and what it means. There's no point in me trying to teach anything if the viewer leaves the video not understanding the concepts in the videos so they can implement it on their own.
      Good luck on your save system, bud. :) My first was daunting as well, but it's not so bad if you go about it the right way.

  •  4 роки тому +53

    I thought I knew how to save and load properly, turns out I was missing on some nice stuff. Amazing as always.

    • @GameEndeavor
      @GameEndeavor  4 роки тому +8

      There's always something new we can learn and improve. I find stuff I've been missing out on practically every day. :) Thank you for watching.

  • @ludosgd
    @ludosgd 4 роки тому +25

    I CAN’T believe it’s this easy. Thank you, this topic was kind of an elephant in the room, I’m this helped me a lot, finally I dealt with it. Keep up the good work!

    • @GameEndeavor
      @GameEndeavor  4 роки тому +6

      Right? I've always found the lack of binary file saving to be pretty odd, given how simple it is. I'm glad it helped, thank you for watching!

  • @lennertplayz
    @lennertplayz 2 роки тому +18

    you forgot to say how you access those variables to reassign them (when starting the game)
    The way you access variables in the list / dictionary is:
    player_data["health"]
    or really any variable in the library with [brackets] and ""
    so you have a health variable, and a "health" variable in the dictionary list.
    Then you just add:
    health = player_data["health"]
    to the load function.
    hope this helps!

    • @villagerwerman
      @villagerwerman 2 роки тому

      Thank you, this helped me. But now, everytime when i restart game or press load before saving, player data gets corrupted. Labels with variables just say "NULL". Do you know any solution for this?

  • @andrewwebberley2294
    @andrewwebberley2294 3 роки тому +5

    Great straightforward tutorial! This is exactly what I was looking for!

  • @Ric_93
    @Ric_93 4 роки тому +3

    Your channel is a literal BLESSING. I don't have a lot of time to work on game dev and I love how your videos just get to the point!
    Save/Load data is something I have a hard time with and I'm learning a ton from this video

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      Thank you! That's been the goal of this channel from the start. Information but dense without the usual tutorial fluff / handholding. Modeled after the style of tutorials that I desire, because I also don't have the time to sit through half an hour of 5 minutes worth of information.

  • @joelchrono
    @joelchrono 4 роки тому +16

    I was starting to miss your videos, and you just made the kind of tutorial I needed. Thanks so much!

    • @GameEndeavor
      @GameEndeavor  4 роки тому +4

      Ha, thanks for watching. :) Sorry for the disappearance. Got a little busy for a bit, but I should be back now, so expect plenty more videos! Thank you for watching.

    • @joelchrono
      @joelchrono 4 роки тому

      @@GameEndeavor Oh yeah, I know! 2 jams in such a period of time must have been a bit time consuming

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      @@joelchrono Wasn't just the jams, I had a bit going on before that, but yeah jams require so much attention, especially the week long Kindred Jam, lmao. :)

  • @aureli4nus
    @aureli4nus 4 роки тому +3

    Hey, i'm really glad i found your channel, this is golden and i appreciate the effort for putting subtitles in your videos, keep up the good work buddy!!

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      Thank you! It's surprisingly no effort. I just upload my script and UA-cam transcribes it for me. :) A feature I wish more people took advantage of.

  • @ofAwxen
    @ofAwxen 3 роки тому +1

    This is the best tutorial on saving by far. So much info in 10 minutes. Thank you.

  • @skogkatt651
    @skogkatt651 3 роки тому +2

    This was so simple that I thought I missed it. Thank you!

  • @darthnegativehunter8659
    @darthnegativehunter8659 2 роки тому

    VERY helpful. because you go full on the detail and not miss important bits. thank you

  • @TheRealKaiProton
    @TheRealKaiProton 2 роки тому

    Epic!
    Just Epic,
    all the save data videos and web pages Ive looked at never went so deep into how it works, or even where the file was saved,
    and worse, none ever said the order of read and write matters, I kinda thought it did, but Ive not tried anything yet,
    I really like the encryption with pass, excellent stuff!

  • @alexanderglassgames4170
    @alexanderglassgames4170 2 роки тому

    Cool video! I'm just starting off with Godot and I had no idea about how to save anything but a scene. I'll make sure to play around with all this until I get the gist of it. Thanks!

    • @GameEndeavor
      @GameEndeavor  2 роки тому +1

      I'm glad it was helpful. :) Good luck with Godot!

  • @rainingrainy152
    @rainingrainy152 4 роки тому +2

    Amazing as always! Glad your back to making more tutorials :D

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      Thank you! I'm looking forward to making more. :)

  • @anthonygill718
    @anthonygill718 3 роки тому

    Thanks for pointing out the native encryption! Very helpful!

  • @LuizAntonio_Gameplay
    @LuizAntonio_Gameplay 2 роки тому

    Congratulations for the video, it's wonderful.

  • @youngwood5704
    @youngwood5704 3 роки тому +3

    Lol. Sometimes I am really not expecting your humor and it just gets me haha.

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      Glad to hear it. I do like to be sneaky with it sometimes. :)

    • @youngwood5704
      @youngwood5704 3 роки тому

      @@GameEndeavor Hey question. does using this make a new JSON file every time you run the save function because of var file = File.new()? Total noob here tryna figure this out.

    • @GameEndeavor
      @GameEndeavor  3 роки тому +1

      @@youngwood5704 It doesn't. It makes a new File resource which opens the file and reads the data from it.

  • @Tech-Rookie
    @Tech-Rookie 4 роки тому

    Thanks sooooooo much. This couldn't have come at a better time.

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      Thanks for watching! Glad it was useful to you. :)

  • @davidjohnhamm
    @davidjohnhamm 4 роки тому +1

    thanks for this. this is exactly what was causing me to do some major head scratching

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      Glad I could help, thank you for watching. :)

  • @gokceyldz3626
    @gokceyldz3626 Рік тому

    I have finally understand the save and load logic thanks to you!

  • @cal_azure5676
    @cal_azure5676 4 роки тому +1

    I was about to give up on making my game but this video saved me sooo much. Thank you!

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      Glad I could be of use. :) Thank you for watching!

    • @cal_azure5676
      @cal_azure5676 4 роки тому

      Are you going to do a second part to this?

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      @@cal_azure5676 I assume you mean to cover how to load levels as they were saved? ie with an rpg you might save the player's location, treasure chests looted, enemies defeated, etc? And use that data to instantiate the world. It's the only thing I could imagine I'd need to cover in a second part.
      Yeah, it's on the list. It's not something I intend to cover right now. I need more experience with the style of games that require this type of system. Mario style platformers don't really need such a robust saving system, so I don't have as much experience in this area. But I plan to start an ARPG series at some point which is where I would cover such a thing.

    • @cal_azure5676
      @cal_azure5676 4 роки тому

      Yeah that’s what I mean

  • @oluwafemiosedele6411
    @oluwafemiosedele6411 4 роки тому +1

    Awesome tutorial! Would you please make a video on how to lock and unlock levels/ stages? I'm badly in need of one and can't seem to find any. Thanks!

  • @Barwani
    @Barwani 4 роки тому

    Well made as usual! Well done GE!

  • @TakemuraGoro
    @TakemuraGoro 2 роки тому

    Thnx a lot. Very Useful!

  • @TrueGawa
    @TrueGawa 3 роки тому

    Thanks mate, this was really helpful!

  • @jzxakuma9405
    @jzxakuma9405 3 роки тому +7

    Hey is there a way to save scene name so that I can load and immediately use change_scene on the save file
    Btw sorry if there is an obvious answer to my question cus I'm in the 1st week of learning godot

  • @robertoaguiar6230
    @robertoaguiar6230 2 роки тому +1

    Wow, this was an incredible tutorial with so many tips

  • @TheBotEmpire
    @TheBotEmpire 4 роки тому

    Great video direct and to the point love it :)

  • @deenie5678
    @deenie5678 4 роки тому +2

    howdy such a great video I'ma try this in my game
    omega 3 and all that keyboards need love too

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      Honestly the best comment I've ever received.

  • @SuperQuwertz
    @SuperQuwertz 3 роки тому

    Awesome, I love your tuts

  • @Alenvei
    @Alenvei 4 роки тому

    You're the BEST, thank you and keep it up ! :)

  • @JeanVermeersch
    @JeanVermeersch 3 роки тому +3

    That's a great tutorial, thank you :) I was thinking it was way harder than that. Do you have any idea of how to create an autoload saving system? I was thinking maybe by implementing a timer with a signal that each 30 seconds the game will save automatically, but I ran into some weird godot errors 🤔

  • @simmzzzz
    @simmzzzz 2 роки тому

    Amazing tutorials as always

  • @Alternalo
    @Alternalo 2 роки тому

    How do you save and load multiple variables? Like you would have other variable to save than "data" here.

  • @Icie145
    @Icie145 3 роки тому

    so my saving function is on the other scene, and the loading function is on the title screen scene, does it still works tho?

  • @Wolfyxon
    @Wolfyxon 3 роки тому

    Thx!
    I thought it's very difficult but it is very easy!

  • @tommylin7722
    @tommylin7722 3 роки тому

    How can I automatically assign the value to the dictionary so that it is updated as the player is updated?

  • @DrJoe-sm9no
    @DrJoe-sm9no 3 роки тому

    Hi- what would happen with this process if you released a new (update) of your game. Would it create a whole new file, and the player would have to start again, or would it be smart and read off of the same fil as in the previous version? If this happens, how would you fix it? Thanks!

  • @TCKYATO
    @TCKYATO 2 роки тому

    I cant export project! Help me!
    My exported game works fine in the editor, and the debug export but not if it isn't a debug export

  • @studioatof3744
    @studioatof3744 Рік тому

    So in the func load_game I added unlockedLevels = player_data. So when it's loaded the data from before will be what determines # of levels unlocked. But the player_data is written as unlockedLevels:2, (2 is from the save). So help me how do I get the 2 and nothing else? (Because unlockedLevels needs to be a int/float not a string)

  • @shashanksahu9230
    @shashanksahu9230 3 роки тому

    i have a littler problem, when i write a file multiple time it append in the current file. but i want the previous content to be removed. how to do so?
    basically, how to overwrite the content ?

  • @aeolian951
    @aeolian951 2 роки тому

    What if I want to implement and save a new thing into my game? I cannot save it without deleting my save file, right?

  • @batatachibbbez
    @batatachibbbez 4 роки тому +1

    tbh i still dont understand it but i have watched about 10 tutorials on how to save n load and this is by far the best one

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      It can be tricky to get started. I hated trying to learn it when I started. If you dabble with it long enough then hopefully you'll get the hang of it. :)

    • @batatachibbbez
      @batatachibbbez 4 роки тому

      @@GameEndeavor thanks man i appreciate your work so much do you have instagram??

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      @@batatachibbbez Thank you! Glad you find it useful. I don't. Discord and Twitter only atm. :)

    • @batatachibbbez
      @batatachibbbez 4 роки тому

      @@GameEndeavor I would love to join your discord later but I don't have discord at the moment so I will join tmr or smth KEEP UP THE GOOD WORK ITS ESSENTIAL😂😂👍👍🤝🤙

  • @auscan7739
    @auscan7739 2 роки тому

    is there any way that we can save the current state of the game automatically I don't want people to click buttons to save and load the game, most of the mobile games doesn't have those buttons and when we exit and enter all the things we do saved automatically, I really don't know how we can do that

  • @gingerageousgames613
    @gingerageousgames613 4 роки тому +1

    Fantastic as usual.

  • @giulio915
    @giulio915 3 роки тому

    how i can load the game after saving? (i mean restarting the game by the point i saved)

  • @bongblender
    @bongblender 4 роки тому

    How to use json with gdscript to make a system, where if I completed a level, next level will be unlocked... Like candy crush...

  • @galacticquasar9944
    @galacticquasar9944 3 роки тому

    Honestly, I've been trying to do this for months but I couldn't get my head around other tutorials. This helped me a lot and you did a good job at explaining and walking us through the process. The only thing I don't get is how do I actually get the data from the player and link the data in "var data" together.

    • @GIANMANSUPER
      @GIANMANSUPER 2 роки тому

      yeah. that's everyone's problem probably, saving is easy as there are godot documentations specifically for that, this tutorial would be actually useful if he could have tought us how to access that data and load it.

  • @killingfeveronline_archives
    @killingfeveronline_archives 4 роки тому

    The source code only contains empty folders, when will the source code be uploaded?

  • @AgemarkGaming
    @AgemarkGaming 2 роки тому

    Bro please help me I learn c but game make code are Different why

  • @palerite
    @palerite 2 роки тому

    Hi!
    I made my save system with this tutorial long ago, but I haven't done the encryption part. Now when I'm trying to do it it returns an error:
    open_and_parse: Condition "magic != 0x43454447" is true. Returned: ERR_FILE_UNRECOGNIZED
    Can you help me?
    Sorry for my (maybe)bad English

  • @eboatwright_
    @eboatwright_ Рік тому

    Thank you!

  • @vishwas5371
    @vishwas5371 3 роки тому

    Woah! Thanks a lot!

  • @jaimieself4230
    @jaimieself4230 10 місяців тому

    If i encrypt the data the whole things stops working for me and i get error 15 which seems to be the unrecognised file error. Any idea whats going on here?
    EDIT: I figured it out. When adding the encrypted part you have to delete the unencrypted data file, then when you play the game again it re-created it and it works.

  • @NgaeGameStudio
    @NgaeGameStudio 2 роки тому +1

    Hello thanks for the tutorial.
    How do you work if update new variables after save and load data?
    Let say
    Var hp = 100
    Then save and load
    Then i make new variables
    Var defense = 50
    If i load my data
    The godot engine said that
    Defense = null
    Yeah it happens because defense is not in data yet. I need to save the game but it will reset all data, please could you explain to me how?
    Hoping i could see new tutorial about saving data on Google play service.
    I dont think this could help player to reopen their game on another phone without moving the data files

  • @edwin_the_penguin
    @edwin_the_penguin Рік тому

    At 5:34, is it OK that file.close() is under the if conditional? What happens if error != OK and file.close() is never called?
    Thanks for the great tutorial!

    • @GameEndeavor
      @GameEndeavor  Рік тому

      If it errors then the file never opens, to my knowledge. :) I've never had an issue doing it this way.

  • @xezzee
    @xezzee 3 роки тому

    This leads me to the rabbit hole why I never make games. I want to be able to everything so I do nothing when I can't do one thing from seven things :D
    Example what I want to be able to do: First how to add ability to people to save custom keys -> Then have ability to safe file saving these keys also so it remembers your options and stuff on top of competed levels and unlocked levels xD and power ups, unlocks....
    So not only do I need to learn who to make safe files I need to know how to make rebindable keys :( that the game remembers... so I often just give up. Maybe this time I have patient to learn one of these systems

  • @1kick234too
    @1kick234too Рік тому

    I finally got it to work big brain

  • @naraz927
    @naraz927 2 роки тому

    i am saving my player position,it saves and loads it but then how do i apply the loaded position to the player?

    • @GameEndeavor
      @GameEndeavor  2 роки тому

      You need to give that information to the player and have them use it. Saving a game is a whole other much larger topic unfortunately.

  • @charleshuntley9328
    @charleshuntley9328 3 роки тому

    how did you make the ui in the beginning of the video? it look nice.

    • @GameEndeavor
      @GameEndeavor  3 роки тому +1

      It has been awhile, I don't remember. I do know I spent way too much time on it for a 5 second bit, lol.

  • @TheConceptGuy
    @TheConceptGuy 4 роки тому

    To save "position" of my object and player , should we use store _float ????

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      You can if you want, or you can store it in a dictionary like demonstrated. If you use store_float() then you'll need to read it in the exact same order that your read it.

  • @brank134
    @brank134 3 роки тому

    Thank you so much dude!

  • @Csarvs8
    @Csarvs8 3 роки тому

    Thank You!❤️

  • @lolodachi
    @lolodachi 2 роки тому +1

    Quick question: can you call the save file format however you want, like make it a .sav instead of a .dat?
    Great tutorial, very clear and helpful, gonna keep it handy!

    • @GameEndeavor
      @GameEndeavor  2 роки тому +5

      Yes, the filename doesn't matter one bit as far as I know. You could even call it .png if you wanted, lol.

  • @danieldrew2356
    @danieldrew2356 4 роки тому +1

    What's your view on using config files to save data? is it less efficient?

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      I would imagine it is, but I don't know the specifics of it so I wouldn't quote me. But I would imagine that File is more efficient at reading and saving data, since it's done sequentially. Whereas ConfigFile uses the whole tag system and likely needs to iterate through the file each time you get a variable. If so then this could be quite the slow down for really large files. Also I would imagine it's a lot more space efficient since ConfigFile stores everything as a string, depending on what you're saving.

  • @nemene8585
    @nemene8585 3 роки тому

    i chacked a lot of times and for some reason the file never saves

  • @MyFirstHandle
    @MyFirstHandle 2 роки тому

    Does this work well involving procedurally generated levels saved as a chunk?

    • @GameEndeavor
      @GameEndeavor  2 роки тому +1

      It would require more work, but yeah you can save anything in a binary format.

  • @frsaken5458
    @frsaken5458 4 роки тому

    Thanks, yu help me a lot

  • @dodderss
    @dodderss 3 роки тому

    How would i save the data from a different scene?

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      With the use of a Singleton I would imagine. Depends on the layout of your game.

  • @asthalis
    @asthalis 3 роки тому

    Thanks for your great tutorial !
    I have a question about it : when I use save and load for a big array (I work on a "game of life" version) with overwritting, the new file is getting bigger and bigger every time. Do you have a clue where this comes from ? I checked the "close file" in my code.

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      The only thing I can think of is you're appending more data into the array or the file resource is persistent and accumulating data. I would inspect the contents of the array and the file being saved.

    • @asthalis
      @asthalis 3 роки тому

      @@GameEndeavor
      Thank you, I thought about unexpected appending data too. I think I will check the code with a smaller array first.

  • @canaldosoninho
    @canaldosoninho 4 роки тому +1

    there is nothing in the git hub zip file

  • @RafaFiedo
    @RafaFiedo 4 роки тому

    very nice tutorial!

  • @Gost-nf3cr
    @Gost-nf3cr 4 роки тому +4

    i have a question does godot support a smooth animation i mean if you have 2 pictures and it make automatik a animation from frame 1 to frame 2 does this exist?

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      As in, will it generate sprites in between those two frames? No. That kind of thing would require machine learning and not the purpose of Godot.

    • @Gost-nf3cr
      @Gost-nf3cr 4 роки тому +1

      ​@@GameEndeavor no i mean like i have a red color and i want to smoothly fade in to a green color would that work?

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      @@Gost-nf3cr Yeah, you can use an AnimationPlayer, and keyframe the module or self_modulate from red to green. Or you can use a tween.

    • @Gost-nf3cr
      @Gost-nf3cr 4 роки тому

      @@GameEndeavor ahhh yes i see tnx soo much

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      @@Gost-nf3cr You're welcome. :)

  • @Gost-nf3cr
    @Gost-nf3cr 4 роки тому +1

    omg tnx SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO much

  • @zeke.mp3343
    @zeke.mp3343 3 роки тому

    My game does not save or load help me

  • @frenchiestfry7306
    @frenchiestfry7306 Рік тому

    Does this work in Godot 4?

  • @oluwafemiosedele6411
    @oluwafemiosedele6411 4 роки тому +2

    I want my game to load a specific scene when I press play, and I want the game to change what scene will be loaded when a certain scene if loaded for the first time. Basically, the first time you play, you will go to scene one. If you get to scene two, the next time you play, you will go to scene two I use Godot 3.1.
    Please, how do I go about this?

    • @VerMishelb
      @VerMishelb 4 роки тому

      I assume you can use a load scene which will check for the save and redirect you wherever you want. I'm sure there is a better way to do this thought.

    • @nemene8585
      @nemene8585 3 роки тому

      just sve a string "" of the scene ant then when you load it yust load it into a change_scene()

  • @abstractqqq
    @abstractqqq 3 роки тому

    Thank you, very helpful. One thing, should we put file.close inside the if branch? I am guessing if there is an error, the file will close automatically?

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      I assume that if there is an error then the file doesn't even open, but I'm not 100% certain about that.

    • @abstractqqq
      @abstractqqq 3 роки тому

      @@GameEndeavor Right, that makes more sense. Thanks!

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      You're welcome. :)

  • @QahnaarinDovah
    @QahnaarinDovah 3 роки тому

    Absolutely fantastic tutorial! Not only did you show us what to do but you told us why and made it entertaining, too.
    I've been working on actually using the data that is loaded but one thing that keeps tripping me up is switching to the scene once the dictionary has loaded the data. I have it save to a load_scene variable and then have it call get_tree().change_scene(load_scene) but it can't parse it correctly.
    So i'm wondering, how do you actually switch to a scene that was saved and loaded?

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      This just saves data. It doesn't save the scene itself. That's a whole other topic that is quite challenging. The typical way to handle this is to save the data you would need to recreate the scene yourself.

    • @traceletz6786
      @traceletz6786 Рік тому

      @@GameEndeavor I'm kinda late, but I'd greatly appricate you doing a tutorial on doing exactly this. Being able to do it between scenes is needed for a lot of games and there aren't many great tutorials on it.
      Or if there are they use a system or method that differs from what you do in this video by a bit or have other linked videos you need to watch before you get to swapping the scenes.

  • @luislodosm
    @luislodosm 4 роки тому +1

    Perfect tutorial

  • @klesus
    @klesus 3 роки тому

    5:28 Shouldn't you want to close the file regardless if the writing throws an error or not? Same with reading the file at 6:25.

    • @GameEndeavor
      @GameEndeavor  3 роки тому +1

      I assume that if the file errors then it doesn't open in the first place. Opening errors are things like bad paths, no permissions, corrupted files, etc.

  • @martinpellicer8489
    @martinpellicer8489 4 роки тому

    Hi excellent video! but how I can get the value when loading? eg: if I save "points" = 100 in the dictionary, when loading, which var is saving the value to manipulate it ? Sorry I don´t speak english and I can´t get all that you say

    • @GameEndeavor
      @GameEndeavor  4 роки тому +2

      Howdy. :) So you put the value into the dictionary, and then write it to the file with `store_var()`. When you load the game, you'll load the dictionary with `get_var()`. This will return the dictionary that you need to store into a variable. You then use this dictionary as you would any other dictionary.
      So `var data = {"score" : 1900}` save it with `store_var(data)`, retrieve it with `var data = get_var()`, and then you can get the score with `data.score`. Hope that helps, let me know if not. :)

    • @martinpellicer8489
      @martinpellicer8489 4 роки тому

      Game Endeavor got it!! I was trying to manipulate data that is a dictionary, missing data.score that is the variable thanks a lot!!! I wish you the best

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      @@martinpellicer8489 Glad you sorted it out, bud. :)

  • @buckeyewill2912
    @buckeyewill2912 4 роки тому

    Will this work with a mobile app? If not is there a way to make a save system for a mobile app?

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      I've never developed for mobile, so I'm not sure. I guarantee there is though, and I wouldn't be surprised if this method worked.

  • @themissingbracket
    @themissingbracket 3 роки тому

    does it work in android? if yes are there any changes i must do?

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      I haven't developed for android so I wouldn't know.

  • @mrlonelyFilms
    @mrlonelyFilms 4 роки тому

    Thanks man, how do i tell godot what level to load from the file, i have a continue button and nothing that i do works

    • @GameEndeavor
      @GameEndeavor  4 роки тому +1

      You could save the file path to the level and use that in your level loading logic.

    • @mrlonelyFilms
      @mrlonelyFilms 4 роки тому

      @@GameEndeavor really not helpful, but thanks for trying :D

    • @mrlonelyFilms
      @mrlonelyFilms 4 роки тому

      @@GameEndeavor And sorry for bothering you, how do i access the json file in the start menu to tell godot that i want the "current_lvl" from the json, to load?

  • @snakewings
    @snakewings 3 роки тому +1

    Can I also put my save data in the global script

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      You can put it wherever you like. :)

  • @Code_Machine
    @Code_Machine 4 роки тому

    Oh, yeah. Finally some good fucking tutorials

  • @saadabdulhussein2930
    @saadabdulhussein2930 3 роки тому

    thanks

  • @neondude
    @neondude 4 роки тому

    the github repo which you linked is empty. may be you didnt push your commit ?

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      I did, not sure why the folders were empty since I did it as one push. It pushed the folders just not their contents. I deleted the repo and reposted though. Seems to be fine now, let me know if not.

  • @tommylin7722
    @tommylin7722 3 роки тому

    and if its possible an automatic save system

  • @loxirod8874
    @loxirod8874 3 роки тому +5

    damn that secret password is not blured its: "P@paB3ar6969"

  • @ShakeyBox
    @ShakeyBox 2 роки тому

    Nice.

  • @TheConceptGuy
    @TheConceptGuy 4 роки тому +4

    How to save "scene where we were at last" ?

    • @mjayar7432
      @mjayar7432 4 роки тому +1

      You can save the file path of the scene and load it.

    • @attilanemeth6204
      @attilanemeth6204 3 роки тому

      i also want to know this, but i can't figure out where i have to start.. :\

    • @Eviled
      @Eviled 3 роки тому

      @@attilanemeth6204 try looking up what you can do with autoloads / singletons, that might be a good starting point

    • @attilanemeth6204
      @attilanemeth6204 3 роки тому

      @@Eviled Thank you, after i wrote it, i solved my problem, so i know how it works and what can i do with the file or configfile :)

    • @Eviled
      @Eviled 3 роки тому

      @@attilanemeth6204 alright

  • @AniketSingh-hr8mi
    @AniketSingh-hr8mi 4 роки тому

    nice!

  • @ezion67
    @ezion67 3 роки тому

    Hi. Maybe someone already noted this to you but... When you blur text on screen, for example something similar to: Pap@B3arKINKY, better make sure to blur all of it.

    • @GameEndeavor
      @GameEndeavor  3 роки тому

      Yup, so many people that I pinned a comment about it. It was a joke, bud.

  • @adamsmiddy
    @adamsmiddy 4 роки тому +1

    How you so good at this...

    • @GameEndeavor
      @GameEndeavor  4 роки тому

      Lots of practice. :) Game development is so much fun to me, I absorb it like a sponge.

  • @lucapietrosanti5340
    @lucapietrosanti5340 3 роки тому +3

    I have one question: when you create the dictionary, can you assign global variables that already exist to the dictionary variables?
    just to be clear:
    In my little game I want just to save 3 parameters (collected coins, enemies destroyed and hostages freed). These values are stored in global variables.
    Every time you beat a level, I want these collectables to be stored and saved automatically, so at the next run you will have these values usable to continue your adventure (like... you can continue if you have collected a certain amount coins, destroyed a certain amount of enemies or freed a certain amount of hostages... like credits...)
    I hope it is clear.... sorry but I am really new to the godot engine and in game programming in general, so I apologize if my question seems silly.
    Thank you
    Regards

  • @Fizmox
    @Fizmox 4 роки тому +2

    I've been waiting a long time for a tutorial like this! Thank you GE! But how do I go about saving my player location in a .dat file? + I need to be able to save multiple variables instead of arrays?

    • @GameEndeavor
      @GameEndeavor  4 роки тому +4

      This topic has been requested quite a few times for a while now, so you're not alone. :) Thank you for watching! You just save the player's position as you would any other variable, then when you load the scene you apply the position to the player after loading the level. Level loading is a whole other video on it's on that I'll get into at some point (I need more experience with it myself).
      To store multiple variables, you just call one of the `store` methods again. You can call as many as you like. You just need to make sure that you load the data in the same order that you saved it, because it saves and reads sequentally. I should've demonstrated this, so that's on me.

    • @Fizmox
      @Fizmox 4 роки тому

      @@GameEndeavor Ohh thats how to store multiple variables, It's working, thanks again!

    • @Fizmox
      @Fizmox 4 роки тому

      @@GameEndeavor
      To save the players location in the same scene;
      in the SAVE function;
      var x_pos = 0
      var y_pos = 0
      x_pos = $player.position.x
      y_pos = $player.position.y
      file.store_var(x_pos)
      file.store_var(y_pos)
      then in the LOAD function;
      var x_pos = file.get_var()
      var y_pos = file.get_var()
      console_write(x_pos)
      console_write(y_pos)
      $player.set_position(Vector2(x_pos,y_pos))

    • @GameEndeavor
      @GameEndeavor  4 роки тому +2

      @@Fizmox you can just `store_var($player.position)`, then just `$player.position = file.get_var()`. store_var will store the Vector2, so no need for the extra steps.

    • @Fizmox
      @Fizmox 4 роки тому

      @@GameEndeavorAh okay! I thought you can only store the variables

  • @jvp4951
    @jvp4951 3 роки тому +1

    Hi bro, your video helped me a lot, however I'm still in trouble. My idea is: save the level, when the player passes through a portal at the end of the level, and when the player closes the game, and presses the load button, he will return to the same level he saved. But I don't know how to put that in the dictionary.

    • @jvp4951
      @jvp4951 3 роки тому

      will only be saved when the player passes through the portal at the end of the level and moves to the next level. How can I put this in the script?