Skip to content

Commit

Permalink
content: explain when you want to store return values in lesson 22
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanLovato committed Apr 2, 2022
1 parent c0d6522 commit bdee3d0
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
35 changes: 35 additions & 0 deletions app-practice-screen.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/app-practice-screen.png-2803de6b8f7978f679c93f9f4836ed49.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://app-practice-screen.png"
dest_files=[ "res://.import/app-practice-screen.png-2803de6b8f7978f679c93f9f4836ed49.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
28 changes: 24 additions & 4 deletions course/lesson-22-functions-return-values/lesson.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="Resource" load_steps=23 format=2]
[gd_resource type="Resource" load_steps=25 format=2]

[ext_resource path="res://course/Documentation.tres" type="Resource" id=1]
[ext_resource path="res://resources/Lesson.gd" type="Script" id=2]
Expand Down Expand Up @@ -68,9 +68,29 @@ script = ExtResource( 4 )
content_id = "res://course/lesson-22-functions-return-values/content-qdYOexRj.tres"
title = ""
type = 0
text = "Notice how we assign the result of the function call to a variable. Because the [code]round()[/code] function returns a [i]new[/i] value, we need to store the result.
text = "Notice how we assign the result of the function call to a variable. Because the [code]round()[/code] function returns a [i]new[/i] value, we need to either store the result or use the value immediately.
So we assign the result to a variable."
Above, we assigned it to a variable, but you could also do the following."
visual_element_path = ""
reverse_blocks = false
has_separator = false

[sub_resource type="Resource" id=20]
script = ExtResource( 4 )
content_id = "res://course/lesson-22-functions-return-values/content-izKUdOCQ.tres"
title = ""
type = 0
text = ""
visual_element_path = "visuals/CodeRoundingHealth2.tscn"
reverse_blocks = false
has_separator = false

[sub_resource type="Resource" id=21]
script = ExtResource( 4 )
content_id = "res://course/lesson-22-functions-return-values/content-iGjB7tKR.tres"
title = ""
type = 0
text = "You can assign the return value of a function call if you plan on using it more than once."
visual_element_path = ""
reverse_blocks = false
has_separator = false
Expand Down Expand Up @@ -226,5 +246,5 @@ description = "We lost the function to convert grid coordinates, but we desperat
[resource]
script = ExtResource( 2 )
title = "Functions that return a value"
content_blocks = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 19 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ]
content_blocks = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 20 ), SubResource( 21 ), SubResource( 7 ), SubResource( 19 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ]
practices = [ SubResource( 17 ) ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://course/common/GDScriptCodeExample.gd" type="Script" id=1]

[node name="GDScriptCodeExample" type="TextEdit"]
anchor_right = 1.0
margin_right = -1620.0
margin_bottom = 60.0
rect_min_size = Vector2( 300, 80 )
size_flags_horizontal = 3
text = "set_text(round(health))"
readonly = true
syntax_highlighting = true
show_line_numbers = true
draw_tabs = true
draw_spaces = true
context_menu_enabled = false
shortcut_keys_enabled = false
smooth_scrolling = true
wrap_enabled = true
caret_block_mode = true
caret_blink = true
script = ExtResource( 1 )
min_size = Vector2( 300, 80 )

0 comments on commit bdee3d0

Please sign in to comment.