Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,256 --> 00:00:04,864
Let's get our metal upgrade save data saving and loading
2
00:00:05,376 --> 00:00:06,912
To and from the disc
3
00:00:07,168 --> 00:00:10,240
Before we do still let's configure the directory
4
00:00:10,496 --> 00:00:12,800
Where are Seaham fireworks
5
00:00:13,056 --> 00:00:15,360
So let's go to project project settings
6
00:00:15,872 --> 00:00:18,432
And under the application config section
7
00:00:18,688 --> 00:00:22,784
If you don't see any of the settings go ahead and toggle on the advanced settings here
8
00:00:24,064 --> 00:00:28,160
And we are going to use what called the custom user directory
9
00:00:28,416 --> 00:00:32,000
And if you read this it says that it's going to save user data
10
00:00:32,256 --> 00:00:33,024
To this day
11
00:00:34,048 --> 00:00:38,400
Install Alex playing this more once we get into the actual saving but I didn't click that
12
00:00:38,912 --> 00:00:39,680
To set a timer
13
00:00:39,936 --> 00:00:43,008
And then give you a game and I'm just going to call it
14
00:00:43,520 --> 00:00:44,800
2D survival
15
00:00:45,312 --> 00:00:45,824
Course
16
00:00:46,080 --> 00:00:48,384
Because that's what my project is called
17
00:00:48,640 --> 00:00:49,920
Basically give
18
00:00:50,432 --> 00:00:56,576
Input field whatever whatever folder you want your save data to existing in the user
19
00:00:57,600 --> 00:00:58,880
And then walk around and close
20
00:00:59,648 --> 00:01:02,957
Ok so I'm going to now go ahead and open up our meta progression see Nan
21
00:01:02,959 --> 00:01:04,567
Subtitled by
online-courses.club
We compress knowledge for you!
22
00:01:06,304 --> 00:01:06,816
That
23
00:01:07,328 --> 00:01:07,840
File
24
00:01:08,096 --> 00:01:14,240
And we want to save and load this as all the first thing we want to do is on ready we want
25
00:01:14,496 --> 00:01:16,544
Load the data from the disk if it
26
00:01:16,800 --> 00:01:17,312
Right
27
00:01:17,568 --> 00:01:21,152
So let's create a new load data function
28
00:01:23,200 --> 00:01:24,992
And actually in the car loads
29
00:01:25,248 --> 00:01:25,760
File
30
00:01:26,528 --> 00:01:27,552
That sounds better to me
31
00:01:28,064 --> 00:01:29,856
Unless just right pass on here for now
32
00:01:30,368 --> 00:01:36,512
Let's define a path for saved data so I'm going to up here create a constant variable called
33
00:01:36,768 --> 00:01:37,792
Save file path
34
00:01:38,560 --> 00:01:40,864
And that's going to be equal to in quote
35
00:01:41,120 --> 00:01:41,632
User
36
00:01:42,144 --> 00:01:42,656
Colon
37
00:01:42,912 --> 00:01:44,192
4 / 4
38
00:01:44,448 --> 00:01:46,496
And then whatever whatever you want to call the
39
00:01:46,752 --> 00:01:48,288
What's a game that's
40
00:01:49,312 --> 00:01:50,336
So what does the saying
41
00:01:51,360 --> 00:01:53,664
This is a shorthand that could deal use
42
00:01:53,920 --> 00:01:56,992
To point to the user directory on
43
00:01:57,248 --> 00:01:58,784
The players device
44
00:01:59,040 --> 00:02:02,112
Install for Windows this will be in the appdata directory
45
00:02:02,368 --> 00:02:06,720
And I'm not sure what the other directories are on Mac and linux and mobile and all day
46
00:02:06,976 --> 00:02:13,120
But there are designated areas in each of the systems for user data to be stored and Godot
47
00:02:13,376 --> 00:02:14,656
Uses those under the hood
48
00:02:14,912 --> 00:02:18,752
And when we configured in our project settings this custom user
49
00:02:19,264 --> 00:02:21,056
This directory is going to be created
50
00:02:21,568 --> 00:02:23,360
Inside of that
51
00:02:23,616 --> 00:02:24,128
2-years ago
52
00:02:24,896 --> 00:02:28,992
And then this file is going to be the file that were reading and writing to
53
00:02:29,760 --> 00:02:32,832
So now we have the same file path defined let's do this
54
00:02:33,344 --> 00:02:34,368
We're going to say yes
55
00:02:34,624 --> 00:02:35,392
Not
56
00:02:36,416 --> 00:02:38,720
File access dot file exist
57
00:02:39,488 --> 00:02:41,024
Save file path
58
00:02:41,536 --> 00:02:42,560
Just going to return
59
00:02:43,328 --> 00:02:48,448
So saying is if the files are created yet that's fine I'll just use this default data here
60
00:02:48,704 --> 00:02:52,800
Ok and that we're gonna read data is the following we need a grab a file
61
00:02:53,312 --> 00:02:56,896
Am I going to save r file equals file access open
62
00:02:57,152 --> 00:02:59,712
Open the save file path
63
00:03:00,480 --> 00:03:03,296
And we're going to open it with file access
64
00:03:03,552 --> 00:03:04,064
Reed
65
00:03:05,088 --> 00:03:08,160
So that's telling us to open up that file for Reading
66
00:03:08,672 --> 00:03:10,720
And then once we have that file we're going to say
67
00:03:11,232 --> 00:03:13,792
Save underscore dealer is equal to
68
00:03:14,304 --> 00:03:15,072
File
69
00:03:17,120 --> 00:03:19,936
Underscore VR which stands forget variant
70
00:03:20,192 --> 00:03:21,728
Insult that's going to
71
00:03:21,984 --> 00:03:24,544
Get that variant which is going to be our dictionary
72
00:03:24,800 --> 00:03:26,848
So we're going to store this dictionary in the file
73
00:03:27,360 --> 00:03:28,896
And said that to see if the
74
00:03:29,408 --> 00:03:32,992
So central was saying this is our default data for when we have no saved data
75
00:03:33,248 --> 00:03:33,760
And
76
00:03:34,528 --> 00:03:40,160
When the game is loaded or when the save files loaded will just replace that object with whatever is in the
77
00:03:41,184 --> 00:03:42,464
Ok so now I'm ready
78
00:03:42,720 --> 00:03:45,280
We want to do load saved
79
00:03:46,304 --> 00:03:46,816
Just likes
80
00:03:47,840 --> 00:03:49,120
So go ahead and Run the game
81
00:03:49,376 --> 00:03:55,264
And make sure that everything works you shouldn't see any errors at all and if not everything is good to go
82
00:03:55,520 --> 00:03:59,872
Alright son now the fun part let's go ahead and save the data so
83
00:04:01,920 --> 00:04:02,432
Save
84
00:04:02,944 --> 00:04:04,224
Save
85
00:04:04,736 --> 00:04:06,784
And in here what we want to do
86
00:04:07,040 --> 00:04:10,624
To save our file is equal to file access open
87
00:04:11,648 --> 00:04:13,952
I'm going to do the same file path and in this time
88
00:04:14,208 --> 00:04:14,976
We're going to do
89
00:04:15,232 --> 00:04:16,512
File access
90
00:04:18,303 --> 00:04:19,327
Because we're riding day
91
00:04:19,839 --> 00:04:21,887
Sourcing open at file for writing
92
00:04:22,399 --> 00:04:24,447
Never going to save file dad's store
93
00:04:24,959 --> 00:04:25,471
Bar
94
00:04:26,239 --> 00:04:27,519
I'm going to pass on this evening
95
00:04:28,543 --> 00:04:30,079
Ok so it's really dad's
96
00:04:30,335 --> 00:04:31,103
So you can see
97
00:04:31,359 --> 00:04:34,175
Will taking the save data dictionary writing it to that file
98
00:04:34,431 --> 00:04:35,199
And and
99
00:04:35,455 --> 00:04:37,503
Loading it up here and
100
00:04:37,759 --> 00:04:39,807
Assigning that save data back to that
101
00:04:40,319 --> 00:04:42,879
Alright and that's it what just does few lines we've got
102
00:04:43,391 --> 00:04:44,671
Loading and saving
103
00:04:45,183 --> 00:04:46,719
Now one thing that we can do
104
00:04:47,231 --> 00:04:48,511
To check if this is working
105
00:04:48,767 --> 00:04:50,047
We can do this
106
00:04:50,559 --> 00:04:52,351
So on experience Collective
107
00:04:53,375 --> 00:04:54,911
Let's go ahead and just call Steve
108
00:04:55,423 --> 00:04:57,727
After experience is collected every time
109
00:04:59,007 --> 00:05:00,287
And then let's go home
110
00:05:00,799 --> 00:05:01,567
Let's go and play
111
00:05:01,823 --> 00:05:04,127
And then collect one experience while
112
00:05:05,919 --> 00:05:08,735
Ok and then go ahead and close the game after you collect
113
00:05:08,991 --> 00:05:09,759
Experience mi
114
00:05:10,015 --> 00:05:12,063
And now that's remove that save
115
00:05:12,831 --> 00:05:16,927
And then in the load save file function go ahead and print your saved
116
00:05:17,695 --> 00:05:19,487
So print save data
117
00:05:19,743 --> 00:05:21,023
And then Run the game
118
00:05:22,303 --> 00:05:28,447
And look at your helper console and if it worked what you can see is that your metre upgrade currency is now set to
119
00:05:29,727 --> 00:05:30,751
So that means that is were
120
00:05:31,263 --> 00:05:32,799
I'm going to remove that print
121
00:05:33,311 --> 00:05:35,615
And where is the save file actual
122
00:05:35,871 --> 00:05:37,407
Add if you got a project
123
00:05:38,431 --> 00:05:41,503
You can then click on the option open userdata file
124
00:05:42,015 --> 00:05:43,551
And it will take you write 2
125
00:05:44,063 --> 00:05:46,111
Where that file is when you can see in here
126
00:05:46,367 --> 00:05:47,391
Look at the two dates of
127
00:05:47,647 --> 00:05:48,159
Course
128
00:05:48,415 --> 00:05:48,927
Direct
129
00:05:49,439 --> 00:05:50,463
And then also our
130
00:05:50,719 --> 00:05:51,487
James Avery
131
00:05:51,743 --> 00:05:52,255
Which is right here
132
00:05:52,511 --> 00:05:56,095
So that's where our game save actually is on the disk
133
00:05:56,351 --> 00:05:59,679
And the final thing to do before we end this lesson
134
00:05:59,935 --> 00:06:01,215
Call Steve at the
135
00:06:01,471 --> 00:06:01,983
Red x
136
00:06:02,495 --> 00:06:04,799
So what I'm going to do is I'm going to go to my
137
00:06:05,055 --> 00:06:07,871
Arena time manager I'm going to open at
138
00:06:08,639 --> 00:06:10,687
And in here in this group
139
00:06:11,455 --> 00:06:12,223
When we
140
00:06:12,735 --> 00:06:17,599
Put the end screen in place that introduces the fact that the user has
141
00:06:17,855 --> 00:06:18,367
1
142
00:06:19,135 --> 00:06:22,975
What we want to do is we want to call Safe so I'm going to go to my
143
00:06:23,487 --> 00:06:24,255
M
144
00:06:24,511 --> 00:06:27,071
Progression I'm going to call that save
145
00:06:27,583 --> 00:06:28,607
Just like so
146
00:06:28,863 --> 00:06:30,399
Let's go to main
147
00:06:31,167 --> 00:06:33,471
E.ON player died Sydney
148
00:06:33,727 --> 00:06:34,495
The other point
149
00:06:35,007 --> 00:06:36,543
Which where showing the end screen
150
00:06:36,799 --> 00:06:38,335
Let's call meta progression
151
00:06:39,871 --> 00:06:41,919
Save there as well
152
00:06:43,199 --> 00:06:44,735
This is doing essential
153
00:06:44,991 --> 00:06:48,319
Whenever the player loses or winds were going to Save the Day
154
00:06:48,831 --> 00:06:51,391
Alright so that's it for saving and loading
155
00:06:51,647 --> 00:06:56,511
The next step is to make upgrades actually choosable by the player
10839
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.