Now I’m developing a messenger, but since I’m still a beginner, I don’t know how to create a dialogue between users.
I apologize for not finishing the details, I need a dialogue like in a messenger, and not a dialogue with an NPC. Ещё раз извиняюсь.
I think you still need to clarify what you want.
Or rather, what are your problems with what you have planned?
Have you entered the query “Create a chat in Godot” into Google, tried to repeat it, and what specific questions did you have that didn’t work?
For example, something like this.
Also, you should be able to edit your post.
I have a line onready
It lights up red and I don’t know what to do
Above is an example of a blogger, and here’s what I have
extends Control
onready var chatlog = get_node("VBoxContainer/RichTextLabel")
So, you are about to make a chat without knowing basic things…
(Haven’t you been sent to Your first 2D game from the official documentation yet?)))
It will be about @onready and everything else.
You have to understand that when you make a video that was recorded when Godot 4 didn’t even exist yet, there will be some differences… but I made a code from it: everything works if you dig around and think about where the necessary commands went…
I provide the code below, with some comments.
extends Control
@onready var chatLog = $VBoxContainer/RichTextLabel
@onready var inputLabel = $VBoxContainer/HBoxContainer/Label
@onready var inputField = $VBoxContainer/HBoxContainer/LineEdit
# onready -> @onready, also, export -> @export
var groups = [
{'name': 'Team', 'color': '#34c5f1'},
{'name': 'Match', 'color': '#f1c234'},
{'name': 'Global', 'color': '#ffffff'},
]
var group_index = 0
var user_name = "Emilio"
func _ready():
# inputField.connect("text_changed", self, "text_changed")
inputField.connect("text_submitted", text_submitted)
add_message('Godot', "The engine: ")
change_group(0)
# text_entered, -> text_submitted
func _input(event):
if event is InputEventKey:
if event.pressed and event.keycode == KEY_ENTER:
inputField.grab_focus()
if event.pressed and event.keycode == KEY_ESCAPE:
inputField.release_focus()
if event.pressed and event.keycode == KEY_TAB:
change_group(1)
# scancode -> keycode
func change_group(value):
group_index += value
if group_index > (groups.size() - 1):
group_index = 0
inputLabel.text = '[' + groups[group_index]['name'] + ']'
inputLabel.set('theme_override_colors/font_color', Color(groups[group_index]['color']))
func add_message(username, text, group = 0):
chatLog.append_text('\n')
chatLog.append_text('[color=' + groups[group]['color'] + ']')
chatLog.append_text('[' + username + ']: ')
chatLog.append_text(text)
#chatLog.append_text('[/color]')
# bbcode_text -> append_text()
func text_submitted(text):
if text == '/h':
add_message('help', "There is no help written yet.", 2)
inputField.text = ''
return
if text != '':
print(text)
add_message(user_name, text, group_index)
inputField.text = ''
True, after doing this, I found out that there is no internetwork here)))
But it is in other search results.
Thank you, but it’s worth clarifying that I took lessons in the official documentation and if you read the post carefully, you will understand that I am a beginner and some things are difficult for me. I understand what’s happening In code, but it’s hard for me to write it without someone’s help and it’s hard for me to learn English, но стремлю быть лучше. Thanks for your Notes.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.