Godot Version
4.3.stable.mono
Question
Hello,
I’m trying to create a plugin for Godot multi-user support but I’m getting stuck because for some reason when I add a control or really a “VBoxContainer” to the bottom panel (so that you can enter your username, the servers password, and the servers ip address, and so you can start the server or connect to it) it would seem the script on the root of the VBoxContainer gets removed or something because,
- I can’t call the scripts functions manually as I have tried doing.
- The ready function is not called as the print function within it is not working plus it doesn’t change any of the TextEdit’s inputs.
- The plugin.gd file prints just fine.
Here’s the related code:
plugin.gd:
@tool
extends EditorPlugin
const DockScene: PackedScene = preload("res://addons/multiuser/dock.tscn")
var _dockUI: Control = null
...
func _enter_tree():
...
_dockUI = DockScene.instantiate()
add_control_to_bottom_panel(_dockUI, "Multi-User")
print("Multi-User Support plugin enabled.")
...
multi_user_window.gd:
class_name MultiUserWindow
extends VBoxContainer
@export var server_ip : String = "127.0.0.1"
@export var server_port : int = 19325
var username : String = "Host"
var password : String = ""
@export var username_input: TextEdit
@export var password_input: TextEdit
@export var ip_input: TextEdit
func _ready() -> void:
print("Multi-User Window Readied.")
# username = OS.get_name()
# username_input = get_node("./UsernameInput") as TextEdit
# username_input = get_node("./PasswordInput") as TextEdit
# ip_input = get_node("./IPInput") as TextEdit
username_input.text = username
ip_input.text = server_ip
# $ConnectButton.connect("pressed", Callable(self, "_on_connect_button_pressed"))
# $StartServerButton.connect("pressed", Callable(self, "_on_start_server_button_pressed"))
func _on_connect_button_pressed():
username = username_input.text
password = password_input.text
server_ip = ip_input.text
get_node("/root/Plugin").username = username
var tcp_client = TCP_Client.new()
print("Connecting to Server.")
tcp_client.connect_to_server(server_ip, server_port, username, password)
add_child(tcp_client)
func _on_start_server_button_pressed():
username = username_input.text
password = password_input.text
print("Starting Server.")
get_node("/root/Plugin").start_server(username, password)
Edit: Sorry I accidentally clicked to submit the topic early oops.
Edit 2: If you have any question feel free to ask, thanks.