Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Why doesn't this work?glossy-elephant```gdscript
var buttontween := create_tween() #Tween Invalid. Either finished or created outside scene tree.
tween.finished.connect(func () -> void:
#var buttontween := create_tween() #Tweens correctly
for button:Button in action_buttons_v_box_container.get_children():
buttontween.tween_property(button,"modulate:a", 1, 0.3)
)
```
I'm confused as to why this doesn't work when buttontween is defined outside of the lambda but works when defined inside.
I thought that lambdas could access the variables in the outer scope?
It also doesn't give scope errors.
When running the above code I get errors in debugger:
E 0:00:02:0286 dialogue.gd:135 @ <anonymous lambda>(): Tween invalid. Either finished or created outside scene tree.
One of these for each button, with 135 being line 5 above. I don't really understand the error code.22Jul. 11, 2024
Another solution for making buttons appear sequentiallyFlorcAt first I wanted to have the loop await for the button it is currently managing to appear before proceeding to the next.
So I ended up with this solution :
```gdscript
tween.finished.connect(func() -> void :
for button: Button in action_buttons_v_box_container.get_children():
button.modulate.a = 0.0
button.visible = true
var opacity_tween := create_tween()
opacity_tween.set_ease(Tween.EASE_OUT)
opacity_tween.tween_property(button, "modulate:a", 1.0, 0.5)
await opacity_tween.finished
)
```
But as I don't know how threading is managed in Godot I was afraid to stop an important thread and encounter unexpected behaviours later in the module. So in the end I settled with the same solution as the one in the solution of the lesson.
I'm curious though, how much was I risking to break things by using an await there ?11Aug. 25, 2024
Typo in L4.P1 ChecklistBob CornbobThe first line in the checklist says: **`There should be as buttons children`**10Nov. 01, 2024
bug in 'binding call' link?andriesThere is a code fragment in the 'binding call' link section.
The code is:
```gdscript
func _ready() -> void:
health_pack.body_entered.connect(_on_body_entered).bind("health")
coin.connect.body_entered.connect(_on_body_entered).bind("coin")
func _on_body_entered(body: Node, name: String) -> void:
print("Body entered: ", name)
```
... but shouldn't this be:
```gdscript
func _ready() -> void:
health_pack.body_entered.connect(_on_body_entered.bind("health"))
coin.connect.body_entered.connect(_on_body_entered.bind("coin"))
func _on_body_entered(body: Node, name: String) -> void:
print("Body entered: ", name)
```
'.bind' should be called on *on*body_entered instead of connect?10Oct. 08, 2024
I reused old codeeuphoric-sheepI reused my code and dialogue to expand on the original design. I had to do a diff between our code to figure out the functional differences. Then I added the starts of the dialogue I created on a Miro board and numbered so I knew which order they went in for the index.
Great lesson, really felt like I learnt a lot of applicable skills!10Oct. 06, 2024
Error after completing task L4.P2Thrillhouse[https://imgur.com/a/4THXNtk](https://imgur.com/KHLgfPB) - I completed the task and got the tick. I then tried removing display_item("purse") in ready to see what it would do. Then put it back again and now every time I run it crashes out to this: [https://imgur.com/XjREbUY](https://imgur.com/XjREbUY)
I've tried resetting the task in the bottom right list but it give's me the option but then does nothing when clicked.20Sep. 27, 2024
I want to change disabled = false for each button one by one when modulate.a = 1.0next-craneI want to set the button to `disabled = false` only when `modulate.a = 1.0`. This is my previous code (including the comment section):
```gdscript
for button : Button in action_buttons_v_box_container.get_children():
button.modulate.a = 0.0
button.disabled = true
tween.finished.connect(func() -> void:
var button_tween = create_tween()
for button : Button in action_buttons_v_box_container.get_children():
button_tween.tween_property(button,"modulate:a",1.0,0.5)
#button_tween.finished.connect(func()-> void:
#button.disabled = false
#)
)
```
But I found that it waits for all my buttons to have `modulate.a = 1.0` before setting all buttons to `disabled = false`. I want to set them one by one, so I changed it to be set inside `_process`:
```gdscript
func _process(delta: float) -> void:
for button:Button in action_buttons_v_box_container.get_children():
if button.modulate.a == 1:
button.disabled = false
```
But I would like to know if `tween` has its own method to achieve this without having to set it in `_process`. Thank you!10Sep. 19, 2024
Bug when launching scene after editing the create buttons functionHazlarHi,
When I hover the mouse over yes or no the background of the button becomes orange when I validate the choice, during the proposal the previous choice is no longer orange when I hover over it with the mouse.
Example:
Sentence 1: Yes or Not -> [yes]
Sentence 2: Yes or not -> Yes no longer becomes orange when hovered over. And vice versa
[https://school.gdquest.com/courses/learn_2d_gamedev_godot_4/start_a_dialogue/interesting_choices#quitting-the-game-when-done](https://school.gdquest.com/courses/learn_2d_gamedev_godot_4/start_a_dialogue/interesting_choices#quitting-the-game-when-done)20Aug. 27, 2024
Button visibility challengesmart-locustI understand the solution but, I seem to have arrived at this one first before I read the solution and it seemed to work just the same / similarly.
```gdscript
for button: Button in action_buttons_v_box_container.get_children():
button.disabled = true
button.modulate.a = 0
tween.tween_property(button, "modulate:a", 1.0, 0.5)
tween.finished.connect(func() -> void:
for button: Button in action_buttons_v_box_container.get_children():
button.disabled = false
)
```10Aug. 06, 2024
var target_line_idx: int = choices_data[choice_text] I AM CONFUSE!miniature-gazellehello, why does the above line give us the value and not the key ? isn't choices_text the key of the dictionary?20Aug. 05, 2024
L4.P1 I Need Help!Nikita MyshkinI've tried everything already and don't understand what needs to be done.
```gdscript
func _ready() -> void:
for item_name in items_list:
var button := InventorySlotButton.new()
grid_container.add_child(button)
button.text = item_name
button.amount = item_name
# Assign the item's name and amount to the button properties.
# Don't forget to add the button to the grid container.
```
What needs to be fixed here that the numbers finally show up?
70Jul. 29, 2024
I get it, i'll be mindfull of queue_free and tween.finish interactionunderstated-cobraI thought i'll be smart and merge the two `for button: Button in action_buttons_v_box_container.get_children():` into one (the one creating the button and the one inside the finish signal) but this way the tween finish signal callback to a dereferenced button.
Just added a null check inside the tween.finished lambda function to make it work but it shows that getting an update button list at finish signal timing is important.
Almost forgot, these dialogue lessons are super interesting !
edit : typo10Jul. 22, 2024
Code Snippet Missing Double Quotes13eckIn the `Adding choices to the dialogue` section, the first code snippet is missing a double-quote at the very beginning of line 310Jul. 18, 2024
Favorite lessonAlcedoMan, I do love this lesson for all the present topics, in particular the challenge. This make me think about an additional feature: it would be nice to have a favorite system to keep track these kind of lessons.10Jul. 16, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.