summaryrefslogtreecommitdiff
path: root/UI/Lobby.gd
blob: ba76ecc72fb2fe32e741292301eeb9dab484b151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
extends Control


func _ready():
	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():
	var ip := "127.0.0.1"
	if %IP.text:
		ip = %IP.text
	
	return ip


func get_port():
	var port := 1234
	if %Port.text:
		port = %Port.text
	
	return port

func _on_host_pressed() -> void:
	Client.player.username = %Name.text
	Network.host_game(get_port())
	get_tree().change_scene_to_file("res://Stages/world.tscn")


func _on_join_pressed() -> void:
	Client.player.username = %Name.text
	Network.join_game(get_ip(), get_port())
	get_tree().change_scene_to_file("res://Stages/world.tscn")