-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
lesson-25-creating-dictionaries.pot
226 lines (196 loc) · 7.4 KB
/
lesson-25-creating-dictionaries.pot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Translations template for Learn GDScript From Zero.
# Copyright (C) 2024 GDQuest
# This file is distributed under the same license as the Learn GDScript From
# Zero project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Learn GDScript From Zero \n"
"Report-Msgid-Bugs-To: https://github.com/GDQuest/learn-gdscript\n"
"POT-Creation-Date: 2024-12-12 14:39+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n"
#: course/lesson-25-creating-dictionaries/lesson.tres:14
msgid ""
"In the last lesson, we used an array to represent a player's inventory.\n"
"\n"
"With just an array of item names, though, we can't easily keep track of "
"the amount of each item.\n"
"\n"
"Instead, we can bundle the item names and amounts into a single "
"[i]dictionary[/i].\n"
"\n"
"A dictionary is a data structure that allows you to map pairs of values. "
"In the pair, we call the first value a [i]key[/i] as we use it to access "
"the second.\n"
"\n"
"In other words, a dictionary has a list of [i]keys[/i], and each key "
"points to a [i]value[/i].\n"
"\n"
"To define a dictionary, we use curly brackets. A colon separates each key"
" and its value. A comma separates each key and value pair."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:42
msgid "Dictionaries can hold any values"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:44
msgid ""
"Dictionaries can map about any value to any other value.\n"
"\n"
"For example, we can use the name of an item as a key and the amount as "
"the corresponding value. This makes dictionaries excellent for keeping "
"track of a player's inventory."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:66
msgid ""
"Here we matched the name (a string) to the amount (a number). But a key "
"could be a string, a number, or even a vector! \n"
"\n"
"Although we can have all of these different keys, keep in mind that every"
" key has to be [i]unique[/i]. That means we [i]couldn't[/i] have a "
"dictionary like the following."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:88
msgid "We would get the following error."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:106
msgid "In the above example, which key would cause an error?"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:109
msgid ""
"The key [code]\"healing heart\"[/code] appears [b]twice[/b] in the "
"dictionary.\n"
"\n"
"In the above example, Godot wouldn't know whether to return "
"[code]3[/code] or [code]8[/code] when using [code]inventory[\"healing "
"heart\"][/code]. This is why keys need to be unique."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:112
#: course/lesson-25-creating-dictionaries/lesson.tres:113
msgid "\"healing heart\""
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:112
msgid "\"shield\""
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:112
msgid "\"sword\""
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:120
msgid "How dictionaries work under the hood"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:122
msgid ""
"Dictionaries are also called mappings or [i]associative arrays[/i]. Under"
" the hood, they use arrays and several functions to efficiently store and"
" retrieve values across arrays.\n"
"\n"
"Precisely, dictionaries use a [i]hashing algorithm[/i]. Hashing "
"algorithms convert one value into another.\n"
"\n"
"In this case, hashing consists of converting a given key into a unique "
"whole number. The dictionary then uses that number as an array's index!\n"
"\n"
"That's how a dictionary works: when you give it a key, it converts it "
"into a unique index and uses that index to retrieve the corresponding "
"value in the computer's memory.\n"
"\n"
"That's also why you can't have the same key twice: it would map to the "
"same array index, causing you to overwrite an existing value."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:138
msgid "Accessing values"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:140
msgid ""
"We access the value of keys by writing the dictionary name, with the key "
"in between square brackets."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:168
msgid "How would you access how many gems the player has?"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:171
msgid ""
"We need to make sure the key is the same as we defined in the dictionary."
"\n"
"\n"
"In our case, [code]var item_count = inventory[\"gems\"][/code] is correct."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:174
msgid "var item_count = inventory[\"gem\"]"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:174
#: course/lesson-25-creating-dictionaries/lesson.tres:175
msgid "var item_count = inventory[\"gems\"]"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:174
msgid "var item_count = inventory[\"sword\"]"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:182
msgid "Changing values"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:184
msgid ""
"We can also change values directly, which is useful in our case for "
"adding or removing items from the player's inventory."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:214
msgid ""
"In the following practices, we'll use a dictionary to create a player "
"inventory and create a function to change the value of items."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:222
msgid "Creating an inventory using a dictionary"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:223
msgid ""
"Let's give some items to the player.\n"
"\n"
"We use a dictionary for the player's inventory. We defined the "
"[code]inventory[/code] variable for you, but it contains no items yet.\n"
"\n"
"Give the player the following items by adding the correct keys and values"
" to the dictionary:\n"
"\n"
"- Three \"healing heart\".\n"
"- Nine \"gems\".\n"
"- One \"sword\".\n"
"\n"
"The keys should be text strings, and the values whole numbers."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:244
msgid ""
"Collecting items is fun, but we need a good way to store them. Write a "
"dictionary to display the player's items."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:249
msgid "Increasing item counts"
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:250
msgid ""
"We want to change the item counts in the player's inventory whenever the "
"player picks up or uses an item.\n"
"\n"
"We've started the [code]add_item()[/code] function for you.\n"
"\n"
"The [code]inventory[/code] dictionary should use the "
"[code]item_name[/code] parameter as the key to access its values, and we "
"should increase the value by [code]amount[/code].\n"
"\n"
"To test this practice, we'll use your [code]add_item()[/code] function to"
" increase the item count of Healing Heart, Gems, and Sword."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:266
msgid ""
"The player might walk over a pick-up or find something in a chest, so we "
"need a way to change the item counts in our inventory."
msgstr ""
#: course/lesson-25-creating-dictionaries/lesson.tres:270
msgid "Creating Dictionaries"
msgstr ""