 So last time we did basic saving we have the opening of the file at the beginning So whenever we load the game we get all the information from the save.txt and We have here the saving so we execute this function every minute If you haven't seen this part of the tutorial I want to follow along you can press on the corner I think it's that one and you can go to the previous video But otherwise it's very simple what we want to do now is that whenever we start Clicking here and we upgrade the auto clickers We want to get also this information like how many we have and what's the current price to the save file So that when we close it and we open again We still have that information here We are only saving how many we have because it's Only storing the data here the count So what I'm gonna go over today is going to give you like a general idea on how you can start saving a lot of data That you want from different nodes to a save file First of all since I know that I will be accessing the information on these nodes I will want to group them right now. They are just here in the wild. So let's create a node And this node will contain the rest of them We can actually call this auto clickers clicker Container, okay, so this is the node that we're gonna access whenever we want to save the information The rest of the nodes we don't really need to save like the animation. It doesn't matter when it is The timers is something that's gonna execute no matter what this button is also going to be always The same so this is really the only part that we need to access But before we start with the saving we need to clear up the code a little bit because if you remember These auto clickers are a separate scene and they have a lot of things inside of them They are kind of complicated. I rushed them a little bit when I was doing the translation So we're gonna clear this code up whenever that is clear. We will go back again to the save and load functions and we're gonna Get that information properly to this since we are doing a lot of stuff here when we press and also we are updating the Labels and stuff. Let's go ahead and create a function for updating Which it will contain all the information that we want to update on a single run instead of doing it all the time It's going to take one argument which is going to be the new value What is like the amount that we're gonna change and that is Going to affect the amount So right now what we can do is start replacing this So this is the function that we're gonna use and here instead of amount plus one We can replace it and do amount plus one Now ideally we want to do this as well in the update function So as soon as we update the information there we update the label and Also We want to do the calculation of the price because the price is something that we were calculating every time we clicked We were updating it all the time in the process function and we don't really need to have it there So let's move it out Here as well And The price here, which is this valley that we're gonna tweak a little bit because it was getting out of hand Gonna move it here as well So now on the unbutton press which is the function that we set there. It's only going to Check for the price remove that amount from our Account and then update it. We're gonna be using this function When we load the game so we want to update it and set what's the value that is going to be and The price and everything else will come from that We are not gonna change this for now But we can also get this inside of the update function and the less we have on the process Functions the better so we are executing less things at the same time So because we were setting here on the main scene the values here from the script variables It's going to give you some issues if you want to calculate the price as we're gonna be doing it here So we're gonna store that value on ready Start price is going to be equal to price which is the default and we're gonna do this again When ready that means that when the scene is loaded We're gonna store that price and now we're gonna modify how it's calculated The amount is going to be the new value just in case Like let's use this variable as well and the price that we're gonna multiply it for is going to be the star prices That way it doesn't grow exponentially. It's always going to be the same But there's a case that if you set the amount to zero at the beginning It's going to multiply by zero because this is going to be the new value zero per Incremented can be zero zero per zero zero. Let's add a check here first. So if New value it's not it's equal to zero Let's just set the price equal to the star price and else We do this operation the rest can stay as it is right now and As the last thing of all since we are going to be calculating the price now instead of on the process function in this update value We're just going to call it one ready Update value and This is going to be amount, which is the value that we want So these are all the changes we wanted to have in this Subscene so let's save it and let's go back to the main one Okay, and the main one we will have to do a lot of changes as well First of all here this variable the data is not the same data as we are saving So that means that It will reset on each case and we wanted to have a day a persistent data throughout the entire game We only want to update it when we love the game or when we save it to the tribe So let's move this variable outside of it. So it's going to be a dictionary Which will contain Count it's going to be equal to the count same as we had here so now instead of having this variable here, we can remove it and With data here, we don't have to declare it We just load it from there So now let's save that new information into our file to save it. We need to update this Variable we have here with the current information that we have so in this case Data that count it will be equal to the current count that we have and for each auto clicker We want to track the amount that they have. So since we have five auto clickers, let's create first a dictionary here Clickers It's going to be an empty array Oops for a comma here inside this empty array Let's do the default values that we need. So in this case, it's going to be zero because we start with zero That should be it. We have five zeros there. So now the default is always going to be that now we can do a for loop to check each Auto clicker that we have on the scene. So for AC let's call the auto clicker individually in now, let's select this Auto clicker container and Get children Get children This will give me an Array with all the nodes that we have and we know that each node has a variable called amount Which is the value that we want to get so in this case It will be AC that amount the value that we are looking for and Since we want to store that value inside this we need to first track the index so we are modifying them in Order so index is going to start at zero and at the end of each iteration. We're gonna add A new one. There's probably a better way of doing this if you know, just leave a comment below But this is how I usually do it quickly. It's probably not the best, but I mean it works for me So now we want to access that so data and inside of data day so data and auto clickers and now the index is going to be equal to the amount So that way this is going to go five times. The first time is going to get this Second time is going to save that third time is going to save that for five and we Ended because it's only running five times and each time We're gonna get the value from each of those the rest should stay the same We already updated the data. We already updated the count. We already updated the auto clickers. So we save it no problem and Now we have to update the ready because we want to load the data this remember happens whenever you Start the game. So we do exactly the same as we did here, but in the opposite direction. So Let's start with the loop The AC for the data of auto clickers in data that auto clickers Create the index Starting at zero We added and now we get the container and get children and The index value is going to be index and now we can update value with Our DAC That way we are gonna go through all these zeros. We're gonna get okay. This is one Okay, so the first one has to be one the second one I remember we use this variable because it's the one that we set on this auto clickers in To update the value. Let's try it out because we did a lot of things. We haven't saved yet Let's try it out And if you have an issue with this on the product that we were working before just make sure to delete the save file before On previous tutorial, we were only saving one variable which is count and now we're saving more So each time you are doing these kind of things. Just make sure to clear the saving Information before and then you can continue But let's try it out. Let's see just the regular numbers if I click up to 10 I could do the first two upgrades Let's close it. Let's open it again Now let's do the first update once Okay, we got the auto clicker the price increase. So let's do it twice Okay, second one. Okay, like this. We have two it goes to 20. Okay, let's close it Let's open it again And it seems to be the same as we left it. Let's buy some upgrades Let's see They are so cheap Okay, so five four three two one that way we know that all of them work and Let's close it and open it again And we'll have it Working properly So this is the same concept that you can use for saving and loading things in all of the games It's very interesting that on the documentation they create a different way of doing it instead of doing Like I did here with a group and all I'm going through all of them Like with a node and the children they do it with groups So they they set up a different group. So that way you get Easier way of, you know, creating a dictionary like it's a very recommended way I find it a little bit of a number kill and I can imagine a lot of ways where this can be Not really flexible for all of your needs So I prefer to do it the manual way and Choosing which variables are we going to save? Are we going to delete this car calculate on the fly and things like that? Because this way if let's say you are going to release a future patch on the game that will change the prices of things You don't really want to save the price as a different variable You want to save how many they have and then calculate that afterwards But maybe in your game you really want to save the price as a separate variable So you can do the same or even like more complex things But I prefer to keep track of all the things that you are saving and loading So that's it for today. This is like a very basic but complicated tutorial, but You have all the information you need here for saving and loading in games and the rest if is creativity I really want to thank my new patrons Dave and Baskman 12. I think thank you very much for your support If you have any questions or you want to propose any topic just I'll leave it there. Also as a side note I've been to the go.com recently and I'm gonna try to make a video about it. I don't know I don't have a lot of footage. I was a little bit shy when it came to start recording people's faces So if I can do something with it, I will do it But otherwise if you want to know more about those kind of things I'm always on twitter and you can follow there or just subscribe here And thanks so much and see you next time