From 72863ffa31e27f4c6be862d80472cfb897fccaea Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 19 Nov 2024 15:24:50 +0100 Subject: next commit --- UI/Start.gd | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'UI/Start.gd') diff --git a/UI/Start.gd b/UI/Start.gd index c9a0342..fbfa8db 100644 --- a/UI/Start.gd +++ b/UI/Start.gd @@ -2,13 +2,16 @@ extends Control func _ready(): + multiplayer.peer_connected.connect(_on_peer_connected) + multiplayer.peer_disconnected.connect(_on_peer_disconnected) + if OS.has_environment("USER"): %Name.text = OS.get_environment("USER") elif OS.has_environment("USERNAME"): %Name.text = OS.get_environment("USERNAME") -func get_ip(): +func get_ip() -> String: var ip := "127.0.0.1" if %IP.text: ip = %IP.text @@ -16,13 +19,14 @@ func get_ip(): return ip -func get_port(): +func get_port() -> int: var port := 1234 if %Port.text: - port = %Port.text + port = int(%Port.text) return port + func _on_host_pressed() -> void: Client.player.username = %Name.text Network.host_game(get_port()) @@ -33,3 +37,9 @@ func _on_join_pressed() -> void: Client.player.username = %Name.text Network.join_game(get_ip(), get_port()) get_tree().change_scene_to_file("res://UI/Lobby.tscn") + + +func _on_peer_connected(id): + Network._on_peer_connected(id) +func _on_peer_disconnected(id): + Network._on_peer_disconnected(id) -- cgit v1.2.3