extends Node var peer = ENetMultiplayerPeer.new() var SCENE = "res://scenes/toyland.tscn" func _ready(): $playerNameBox.text = Global.playerName $ipBox.text = Global.lastEnteredIP $portBox.text = Global.lastEnteredPort func _process(delta): pass func _on_button_pressed(): self.queue_free() func _on_host_button_pressed(): var scene_trs =load("res://scenes/hostmenu.tscn") var scene=scene_trs.instantiate() get_parent().add_child(scene) self.queue_free() var alreadyRan func _on_join_button_pressed(): if not alreadyRan: alreadyRan = true peer.close() var IPADD var PORT var intPORT if $ipBox.text: IPADD = $ipBox.text else: $errorLabel.text = "ERROR: NO IP SPECIFIED" return if $portBox.text: PORT = $portBox.text intPORT = int(PORT) else: $errorLabel.text = "ERROR: NO PORT SPECIFIED" return if Global.playerName == "": $errorLabel.text = "NAME CAN'T BE BLANK" return var result = peer.create_client(IPADD, intPORT) var resultString = str(result) $errorLabel.text = resultString prints("Creating client result:", result) if result != OK: printerr("Failed to create client object, please report to Paul/Techwizz") $errorLabel.text = "Failed to create client object, please report to Paul/Techwizz" if result == OK: print("Connecting to server at IP ", IPADD, ":", intPORT, "...") $errorLabel.text = "Connecting to server..." multiplayer.multiplayer_peer = peer await get_tree().create_timer(5).timeout printerr("FAILED TO CONNECT, CHECK INFO THEN TRY AGAIN") $errorLabel.text = "FAILED TO CONNECT, CHECK INFO THEN TRY AGAIN" func _on_player_name_box_text_changed(new_text): Global.playerName = new_text Global.save_data() func _on_ip_box_text_changed(new_text): Global.lastEnteredIP = new_text Global.save_data() func _on_port_box_text_changed(new_text): Global.lastEnteredPort = new_text Global.save_data()