-
-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathlesson.tres
196 lines (166 loc) · 7.53 KB
/
lesson.tres
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
[gd_resource type="Resource" load_steps=20 format=2]
[ext_resource path="res://course/Documentation.tres" type="Resource" id=1]
[ext_resource path="res://resources/Practice.gd" type="Script" id=2]
[ext_resource path="res://resources/Lesson.gd" type="Script" id=3]
[ext_resource path="res://resources/ContentBlock.gd" type="Script" id=4]
[ext_resource path="res://resources/QuizChoice.gd" type="Script" id=5]
[sub_resource type="Resource" id=1]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-jotxF5HU.tres"
title = ""
type = 0
text = "Throughout this course, we've mostly stored numbers in variables. But what if we wanted to store a player's name?
This is where strings help us.
Strings are instrumental in games and applications. We use them to display information such as the description of a spell or the name of a character."
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=2]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-xZPxY8VU.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/RobotWithRegularName.tscn"
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=3]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-DpPwQDwf.tres"
title = "What are strings"
type = 0
text = "A [code]String[/code] is a value type which holds text. To create a [code]String[/code], you write text wrapped in quotation marks ([code]\"\"[/code]). For example: [code]\"This is a text string.\"[/code]
The quotation marks differentiate strings from other value types and function names.
You may remember we've used strings before in previous lessons."
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=6]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-S5AJTESv.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/PrintString.tscn"
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=7]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-5tT6n1Tx.tres"
title = ""
type = 0
text = "Under the hood, strings are arrays of characters. In fact, we can use a [code]for[/code] loop to loop through the characters of a [code]String[/code] as we would with any other array."
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=8]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-lTtcyhcI.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/PrintCharactersInName.tscn"
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=4]
script = ExtResource( 5 )
quiz_id = "res://course/lesson-21-strings/quiz-yqdYOexR.tres"
question = "Which of these are strings?"
content_bbcode = ""
hint = ""
explanation_bbcode = "[code]\"1\"[/code] and [code]\"name\"[/code] are strings.
[code]\"1\"[/code] only contains a character and [i]doesn't[/i] represent the number [code]1[/code].
[code]\"name\"[/code] is made up of four different characters."
answer_options = [ "1", "\"1\"", "\"name\"" ]
valid_answers = [ "\"1\"", "\"name\"" ]
is_multiple_choice = true
do_shuffle_answers = true
[sub_resource type="Resource" id=9]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-b5BnVHAR.tres"
title = "Why we use strings"
type = 0
text = ""
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=10]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-bBWNbDGt.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/RobotWithRegularName.tscn"
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=11]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-6fUqbTxY.tres"
title = ""
type = 0
text = "Every piece of text you see in this app is a string that Godot is displaying for us.
Much like how [code]Vector2[/code] variables make calculations easier, [code]string[/code] variables come with many helper functions and tricks we can use.
We can use arrays to store strings too. This is useful for chaining animations. In this example, the [code]play_animation()[/code] plays a specific animation."
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=12]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-2V6jGvGm.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/ExampleCombo.tscn"
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=13]
script = ExtResource( 4 )
content_id = "res://course/lesson-21-strings/content-ej47MqE8.tres"
title = ""
type = 0
text = "In the next few practices, we'll use strings in combination with different concepts from earlier lessons."
visual_element_path = ""
reverse_blocks = false
has_separator = false
[sub_resource type="Resource" id=15]
script = ExtResource( 2 )
practice_id = "res://course/lesson-21-strings/practice-iGjB7tKR.tres"
title = "Creating string variables"
goal = "Currently, the robot has a number stored in the [code]robot_name[/code] variable.
Change the [code]robot_name[/code] variable so that it's a string instead. You can give it any name you'd like."
starting_code = "func run():
robot_name = 0"
cursor_line = 0
cursor_column = 0
hints = PoolStringArray( "Make sure to use quotes when defining strings to differentiate them from other variable types." )
validator_script_path = "string_error/TestsStringError.gd"
script_slice_path = "string_error/StringError.live-editor/slices/StringError.print_string.slice.tres"
documentation_references = PoolStringArray( "print" )
documentation_resource = ExtResource( 1 )
description = "Give the robot a readable name using a string stored in a variable."
[sub_resource type="Resource" id=16]
script = ExtResource( 2 )
practice_id = "res://course/lesson-21-strings/practice-NwQMqAYV.tres"
title = "Using an array of strings to play a combo"
goal = "In this practice, we'll chain together animations using an array of strings. You might find such combinations in fighting games.
The robot has the following animation names:
- [code]jab[/code] (makes the robot perform a quick punch)
- [code]uppercut[/code] (the robot uses a powerful jumping punch)
Populate the combo array with animation names as strings.
Then, for each action in the array, call the [code]play_animation()[/code] function to play them.
The array should contain three values, so the robot makes these three attacks: two jabs followed by one uppercut."
starting_code = "func run():
combo = []"
cursor_line = 0
cursor_column = 0
hints = PoolStringArray( "Make sure to use (\"\") for each animation name when you add them to the combo array", "Use a for loop and the [code]play_animation()[/code] function for each animation name" )
validator_script_path = "string_array/TestsStringArray.gd"
script_slice_path = "string_array/StringArray.live-editor/slices/StringArray.combo.slice.tres"
documentation_references = PoolStringArray( "play_animation" )
documentation_resource = ExtResource( 1 )
description = "Define an array of strings to unleash a powerful combo."
[resource]
script = ExtResource( 3 )
title = "Strings"
content_blocks = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 4 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ]
practices = [ SubResource( 15 ), SubResource( 16 ) ]