Looks like you're not logged in

Login or Register to continue

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.

  • Resources Not Extending Correctly?LTNoodleburgerWhen I attempt to to do this part of the code, ```gdscript - var dialogue_items: Array[Dictionary] = [] + @export var dialogue_items: Array[DialogueItem] = [] ``` I do get the menu of items that should be expected. Text, expression, body, etc. I get the drop down with no properties to edit. I've tried recreating the steps but same issue. (I'm on Mac OS, if that matters) EDIT: Restarting solved it. Strange, but at least it works now. 8 3 Jul. 18, 2024
  • Suggestion: Challenge Hintwell-to-do-owlI just had a suggestion for the challenge: *Challenge:Can you make it so `is_quit` buttons look unique? You could: ...* For me attempting the first part of the challenge (appending "(quit)") was quite simple, but the second part, creating a type variation for the button required more research into the Godot documentation, and back to previous lessons. I think it would be helpful to provide a link or direct readers to refer back to *M7. SG1 - Making the most out of the theme editor* here, as I do not believe creating a type variation in a theme was covered in this module, or in any of the lessons L1-14 in M7. Thanks for the great lesson! 1 2 Jul. 21, 2024
  • Making is_quit button unique challenge◆ LPMy first thought was using modulate property & it was working partially. But the hover state was not looking good as the text disappears because of modulated color. I made use of get_theme & add_theme override, after finding out about them through autocompletion. Finding functions & property is so easy with the inspector & documentation. I love how sometimes they also include examples. I also found out that I can just use Color() function for changing rgba values all at once, rather than changing their values individually like with modulate.r, modulate.g, modulate.b, etc. Here is the [recording](https://drive.proton.me/urls/PFRD8G5Z5G#YxBVofiolDM8) of the Dialogue scene near it's end. Commented out remove_theme overrides as the game quits afterward. Code for changing quit button appearance on normal & hover state: ```gdscript if choice_item.is_quit == true: var new_stylebox_normal := button.get_theme_stylebox("normal").duplicate() var new_stylebox_hover := button.get_theme_stylebox("hover").duplicate() new_stylebox_normal.bg_color = Color(100.0, 0.0, 0.0) button.add_theme_stylebox_override("normal", new_stylebox_normal) button.add_theme_color_override("font_color", Color(0.0, 0.0, 0.0)) new_stylebox_hover.bg_color = Color(0.0, 0.0, 0.0) button.add_theme_color_override("font_hover_color", Color(1.0, 0.0, 0.0)) button.add_theme_stylebox_override("hover", new_stylebox_hover) button.pressed.connect(get_tree().quit) else: #button.remove_theme_color_override("font_color") #button.remove_theme_color_override("font_over_color") #button.remove_theme_stylebox_override("normal") #button.remove_theme_stylebox_override("hover") button.pressed.connect(show_text.bind(target_dialogue_idx)) ``` 1 1 Dec. 01, 2024
  • Confusing L6.P1 comment in the code bluepillIn the powered_inventory.gd code there is a comment "# Set the power's `image` property to the TextureRect's `texture` property." This caused me to second guess myself for a little while because I misinterpreted it. It may be too late in the day for my brain today, but I thought it says to assign the power's image property value to the value of the TextureRect's texture property. When the opposite is what really needs to be done. 3 1 Aug. 01, 2024
  • Will Version Control Get Introducedsteel_jokersDo you plan to cover any sort of version control in this course (e.g. Git, Subversion, etc.)? I'm looking into how to use git with Godot and, while the syntax of git is simple, the project management side of it seems like very opinionated ground. I'm genuinely curious as to how seasoned developers would apply version controls in their development process. Are there best practices you follow? Do you have a flow that works well for you at GDQuest? 3 1 Jul. 21, 2024
  • Creating Resourcessteel_jokersI love how this lesson stepped through removing the dictionary data model and refactoring to use the resources. The nested diagram earlier in the lesson explaining how the dialog items array would make use of the resources was spot on. The color coding really showed a clean schema of the intended data-structure. Well done! I have one thing I keep tripping over in regard to creating a resource. We created the new resources by right clicking on the lessons folder and selecting: **Create New -> Script...** Each time I would try to implement on my own first, I found myself gravitating toward the: **Create New -> Resource...** I would realize that I had deviated from what we had learned as soon as the Create New Resource dialog box would appear and cancel out of the dialog box. Does the **Create New -> Resource...** essentially do the same as what we had done with generating a new script that extends Resource, or is it there for a different purpose we haven't learned yet? 3 1 Jul. 20, 2024
  • "Spotting Minor and Insignificant Flaws"HazlarA minor embellishment that is purely aesthetic since I think everyone understood the idea and adapted accordingly.. In the lesson in the part: ```javascript -func create_buttons(choices_data: Dictionary) -> void: +func create_buttons(buttons_data: Array[DialogueChoice])-> void: ``` > I hope you like errors because that operation gives us two new fresh errors: Value of type "DialogueChoice" cannot be assigned to a variable of type "String" and Cannot assign a value of type DialogueChoice to variable "target_line_idx" with specified type int. The errors before the ones you mentioned are rather: `Ligne 3 :Identifier "choices_data" not declared in the current scope.` `Ligne 7 :Identifier "choices_data" not declared in the current scope.` ```gdscript func create_buttons(buttons_data: Array[DialogueChoice])->void: #... for choices_text in choices_data: var button := Button.new() action_buttons_v_box_container.add_child(button) button.text = choices_text var target_line_idx : int = choices_data[choices_text] if target_line_idx == INDEX_QUIT_GAME_REQUESTED: button.pressed.connect(get_tree().quit) else: button.pressed.connect(show_text.bind(target_line_idx)) ``` 1 0 Dec. 19, 2024
  • I am at a lossSilinestraI keep getting the error message Invalid access to property or key 'text' on a base object of type 'Resource(DialogueChoice)'. ```gdscript extends Control @export var dialogue_items: Array[DialogueItem] = [] @onready var rich_text_label: RichTextLabel = %RichTextLabel @onready var v_box_dialogue_buttons: VBoxContainer = %VBox_Dialogue_Buttons @onready var audio_stream_player: AudioStreamPlayer = %AudioStreamPlayer @onready var body: TextureRect = %Body @onready var expression_texture_rect: TextureRect = %Expression func _ready() -> void: show_text(0) func create_buttons(choices_data: Array[DialogueChoice]) -> void: for button in v_box_dialogue_buttons.get_children(): button.queue_free() #We loop over all the dictionary keys for choice in choices_data: var button := Button.new() v_box_dialogue_buttons.add_child(button) button.text = choice.text if choice.is_quit == true: button.pressed.connect(get_tree().quit) else: var target_line_id := choice.target_line_idx button.pressed.connect(show_text.bind(target_line_id)) func show_text(current_item_index: int) -> void: # We retrieve the current item from the array var current_item := dialogue_items[current_item_index] # from the item, we extract the properties. # We set the text to the rich text control # And we set the appropriate expression texture rich_text_label.text = current_item.text expression_texture_rect.texture = current_item.expression body.texture = current_item.character create_buttons(current_item.choices) # We set the initial visible ratio to the text to 0, so we can change it in the tween rich_text_label.visible_ratio = 0.0 # We create a tween that will draw the text var tween := create_tween() # A variable that holds the amount of time for the text to show, in seconds # We could write this directly in the tween call, but this is clearer. # We will also use this for deciding on the sound length var text_appearing_duration: float = current_item.text.length() / 30.0 # We show the text slowly tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration) # We randomize the audio playback's start time to make it sound different # every time. # We obtain the last possible offset in the sound that we can start from var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration # We pick a random position on that length var sound_start_position := randf() * sound_max_length # We start playing the sound audio_stream_player.play(sound_start_position) # We make sure the sound stops when the text finishes displaying tween.finished.connect(audio_stream_player.stop) # We animate the character sliding in. slide_in() for button: Button in v_box_dialogue_buttons.get_children(): button.disabled = true #make the buttons disappear button.modulate.a = 0 tween.finished.connect(func() -> void: var button_tween := create_tween() for button: Button in v_box_dialogue_buttons.get_children(): button.disabled = false button_tween.tween_property(button, "modulate:a",1.0,0.3) ) func slide_in() -> void: var slide_tween := create_tween() slide_tween.set_ease(Tween.EASE_OUT) body.position.x = get_viewport_rect().size.x / 7 slide_tween.tween_property(body, "position:x", 0, 0.3) body.modulate.a = 0 slide_tween.parallel().tween_property(body, "modulate:a", 1, 0.2) ``` Dialogue Choice ```gdscript class_name DialogueChoice extends Resource @export var test := "" @export_range(0, 20) var target_line_idx := 0 @export var is_quit = false ``` Dialogue_Item ```gdscript class_name DialogueItem extends SlideShowEntry @export var choices: Array[DialogueChoice] = [] ``` I fairly sure its a misspelling somewhere, but i cannot find it. I apologize if there is an answer else where in the questions of the other students, i am short on time and just really frustrated. 2 0 Dec. 18, 2024
  • Error : Out of bounds get index ’0’ (on base: ’Array[DialogueItem]’)AkariReixxWhen I finish editing func create_button(), this message appears with a yellow arrow pointing to the line var current_item := dialogue_items[current_item_index] . I don't know how to fix this. 6 0 Dec. 08, 2024
  • Challenge Theme Type Variation alternativeandrea-putortiHey there! So, I struggled ridiculously too much with this challenge because for me the Type Variation didn't work. I ended up writing this code: ```gdscript if choice.is_quit == true: button.theme = preload("res://lessons/assets/quit_button.tres") button.text += " (Quit)" button.pressed.connect(get_tree().quit) ``` And before that, I duplicated "main_theme.tres" in FyleSystem, renamed it "quit_button.tres", switched its colour to red (just to make it look different) and saved it. It works smoothly without touching the Type Variation. I still don't understand how to make it work as meant, so if you could please share a step by step, that would be great. Thanks and I hope this helps someone! Cheers 3 0 Nov. 29, 2024
  • Type Variation field needed?PurpleSunriseHello, I completed the challenge of the theme variation button. ```gdscript for choice in choices_data: var button := Button.new() action_buttons_v_box_container.add_child(button) button.text = choice.text if choice.is_quit == true: button.theme_type_variation = "QuitButton" button.text += " (quit)" button.pressed.connect(get_tree().quit) else: var target_line_id : int = choice.target_line_idx button.pressed.connect(show_text.bind(target_line_id)) ``` I followed M7SG1 but I don't think I quite understand the use of the field in the inspector for Type Variation. Even if it's left blank, this still works. Does the property refer to the name we set in the theme editor or the name we give in the inspector? I tried to give two different names and it looks like the type set in the editor is the one which works. Thank you! 5 0 Nov. 11, 2024
  • null vs new()ram876After practice, a question arose. What is the difference between creating a texture property using null and using new(), i.e. how to understand when to use null and when to use new()? In practice, with new() both textures can be defined and will be counted, but if with null, there will be an error with power.image? I understand that with new() the object will be created with default values. p.s. everything is more or less clear in the lessons, but when practice begins (especially the last ones), I start to get lost. If I start looking at the contents of the practice scripts, I realize that I can't do the same at my level. I plan to go over the lessons again from the very beginning, maybe it will become clearer later if I get used to it. 4 0 Oct. 22, 2024
  • L6.P1 Invalid get index powerups_listBort_BortingtonError: Invalid get index powerups_list (on base: 'Resource (PoweredItem)') No idea what im doing wrong. I have 3 items with 1 texture each from the dropdowns in the inspector. func display_powerups(powerups_list: Array[Power]) -> void: for textures in powerups_v_box_container.get_children(): textures.queue_free() for power in powerups_list: var texture = TextureRect.new() texture.texture = power.image texture.add_child(powerups_v_box_container) 4 0 Sep. 16, 2024
  • My dialoguesebbianuuuhi I wrote a short silly dialogue. If you want you can take a look here [https://youtu.be/k2kSpY8aYbU](https://youtu.be/k2kSpY8aYbU) 2 0 Sep. 02, 2024
  • $ used instead of % for line 12 of Full CodeStonemonkeyThe reference to the ActionButtonsVBoxContainer Node is using ` instead of `%` in the Full Code at the end of the Lesson ```gdscript @onready var action_buttons_v_box_container: VBoxContainer = $ActionButtonsVBoxContainer ``` 1 0 Aug. 31, 2024
  • Buttons not appearing at runtime.Abdul Hannan AhmedHere's my `dialogue.gd` ```gdscript extends Control ## UI element that shows the texts @onready var rich_text_label: RichTextLabel = %RichTextLabel ## Audio player that plays voice sounds while text is being written @onready var audio_stream_player: AudioStreamPlayer = %AudioStreamPlayer ## The character @onready var body: TextureRect = %Body ## The Expression @onready var expression_texture_rect: TextureRect = %Expression ## The container for buttons @onready var action_buttons_v_box_container: VBoxContainer = %ActionButtonsVBoxContainer ## An array of dialogue entries @export var dialogue_items: Array[DialogueItem] = [] func _ready() -> void: show_text(0) ## Draws the selected text ## [param current_item_index] Displays the currently selected index from the dialogue array func show_text(current_item_index: int) -> void: # We retrieve the current item from the array var current_item := dialogue_items[current_item_index] # We set the initial visible ratio to the text to 0, so we can change it in the tween rich_text_label.visible_ratio = 0.0 # from the item, we extract the properties. # We set the text to the rich text control # And we set the appropriate expression texture rich_text_label.text = current_item.text expression_texture_rect.texture = current_item.expression body.texture = current_item.character create_buttons(current_item.choices) # We create a tween that will draw the text var tween := create_tween() # A variable that holds the amount of time for the text to show, in seconds # We could write this directly in the tween call, but this is clearer. # We will also use this for deciding on the sound length var text_appearing_duration := (current_item["text"] as String).length() / 30.0 # We show the text slowly tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration) # We randomize the audio playback's start time to make it sound different # every time. # We obtain the last possible offset in the sound that we can start from var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration # We pick a random position on that length var sound_start_position := randf() * sound_max_length # We start playing the sound audio_stream_player.play(sound_start_position) # We make sure the sound stops when the text finishes displaying tween.finished.connect(audio_stream_player.stop) # We animate the character sliding in. slide_in() # We disable all buttons until the tween completes for button: Button in action_buttons_v_box_container.get_children(): button.disabled = true tween.finished.connect( func() -> void: for button: Button in action_buttons_v_box_container.get_children(): button.disabled = false ) ## Adds buttons to the buttons container ## [param buttons_data] An array of [DialogChoice] func create_buttons(buttons_data: Array[DialogueChoice]) -> void: for button in action_buttons_v_box_container.get_children(): button.queue_free() for choice in buttons_data: var button := Button.new() action_buttons_v_box_container.add_child(button) button.text = choice.text if choice.is_quit == true: button.pressed.connect(get_tree().quit) else: var target_line_id := choice.target_line_idx button.pressed.connect(show_text.bind(target_line_id)) ## Animates the character when they start talking func slide_in() -> void: var slide_tween := create_tween() slide_tween.set_ease(Tween.EASE_OUT) body.position.x = get_viewport_rect().size.x / 7 slide_tween.tween_property(body, "position:x", 0, 0.3) body.modulate.a = 0 slide_tween.parallel().tween_property(body, "modulate:a", 1, 0.2) ``` Here's my `dialogue_choice.gd` ```gdscript class_name DialogueChoice extends Resource @export var text := "" @export_range(0, 20) var target_line_idx := 0 @export var is_quit := false ``` and here's my `dialogue_items.gd` ```gdscript class_name DialogueItem extends SlideShowEntry @export var choices: Array[DialogueChoice] = [] ``` For some reason, the buttons don't appear at runtime. I tried restarting the editor, but doesn't work. Can you guide me if I'm doing something wrong? Thanks in advance! 4 0 Aug. 09, 2024
  • Challenge / Type VariationasricbIf I manually add the theme to a button in the scene and write within type variation the "ButtonQuit" that I created, the color changes, so it is created correctly. I have managed to solve it by adding the theme to the button by code like this, but it doesn't seem very optimal to me: ```gdscript if choice.is_quit == true: button.theme = preload("res://assets/main_theme.tres") button.theme_type_variation = "ButtonQuit" button.text = "Quit" button.pressed.connect(get_tree().quit) ``` 1 0 Aug. 01, 2024
  • Buttons not apearing on runtimeRaziel Raznoshere is the code from dialogue.gd: ```gdscript extends Control @onready var action_buttons_v_box_container: VBoxContainer = %ActionButtonsVBoxContainer ## UI element that shows the texts @onready var rich_text_label: RichTextLabel = %RichTextLabel ## Audio player that plays voice sounds while text is being written @onready var audio_stream_player: AudioStreamPlayer = %AudioStreamPlayer ## The character @onready var body: TextureRect = %Body ## The Expression @onready var expression_texture_rect: TextureRect = %Expression ## An array of dictionaries. Each dictionary has three properties: ## - expression: a [code]Texture[/code] containing an expression ## - text: a [code]String[/code] containing the text the character says ## - character: a [code]Texture[/code] representing the character @export var dialogue_items: Array[DialogueItem] = [] func _ready() -> void: show_text(0) func create_buttons(buttons_data: Array[DialogueChoice]) -> void: for button in action_buttons_v_box_container.get_children(): button.queue_free() # We loop over all the dictionary keys for choice in buttons_data: var button := Button.new() action_buttons_v_box_container.add_child(button) button.text = choice.text if choice.is_quit == true: button.pressed.connect(get_tree().quit) else: var target_line_id := choice.target_line_idx button.pressed.connect(show_text.bind(target_line_id)) ## Draws the current text to the rich text element func show_text(current_item_index: int) -> void: # We retrieve the current item from the array var current_item := dialogue_items[current_item_index] # from the item, we extract the properties. # We set the text to the rich text control # And we set the appropriate expression texture rich_text_label.text = current_item.text expression_texture_rect.texture = current_item.expression body.texture = current_item.character create_buttons(current_item.choices) # We set the initial visible ratio to the text to 0, so we can change it in the tween rich_text_label.visible_ratio = 0.0 # We create a tween that will draw the text var tween := create_tween() # A variable that holds the amount of time for the text to show, in seconds # We could write this directly in the tween call, but this is clearer. # We will also use this for deciding on the sound length var text_appearing_duration: float = current_item["text"].length() / 30.0 # We show the text slowly tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration) # We randomize the audio playback's start time to make it sound different # every time. # We obtain the last possible offset in the sound that we can start from var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration # We pick a random position on that length var sound_start_position := randf() * sound_max_length # We start playing the sound audio_stream_player.play(sound_start_position) # We make sure the sound stops when the text finishes displaying tween.finished.connect(audio_stream_player.stop) # We animate the character sliding in. slide_in() for button : Button in action_buttons_v_box_container.get_children(): button.disabled = true tween.finished.connect(func() -> void: for button : Button in action_buttons_v_box_container.get_children(): button.disabled = false ) ## Animates the character when they start talking func slide_in() -> void: var slide_tween := create_tween() slide_tween.set_ease(Tween.EASE_OUT) body.position.x = get_viewport_rect().size.x / 7 slide_tween.tween_property(body, "position:x", 0, 0.3) body.modulate.a = 0 slide_tween.parallel().tween_property(body, "modulate:a", 1, 0.2) ``` 3 0 Jul. 22, 2024
  • @export var dialogue_items: Array[DialogueItem] = []Raziel Raznosits broken nothing shows up, anyone has any ides what could fix it ? , already tried to restart godot didnt worked and also tried to retype it also didnt worked 5 0 Jul. 22, 2024
  • Practice L6.P1 instructionsHludowigTowinaI think I saw a small error in the instructions of practice L6.P1 "Then, add a property named powerups_list with the type Array[Power] to the PoweredInventory resource defined by the script powered_inventory.gd." PoweredInventory and powered_inventory.gd should be PoweredItem and Powered_item.gd respectively 1 0 Jul. 15, 2024
Site is in BETA!found a bug?