extends Node @export var external_address := "127.0.0.1" var master_server_port := 3000 var next_port_num := master_server_port + 1 const MAX_CLIENTS = 4095 func _ready(): PhysicsServer3D.set_active(false) var m = SceneMultiplayer.new() get_tree().set_multiplayer(m, %LobbyList.get_path()) var peer := ENetMultiplayerPeer.new() var error := peer.create_server(master_server_port, MAX_CLIENTS) if error: push_error(error) m.multiplayer_peer = peer m.peer_connected.connect(peer_connected) func peer_connected(id: int): print("Client " + str(id) + " connected to master server") for lobby in %LobbyList.lobbies(): %LobbyList.add.rpc_id(id, lobby.address, lobby.port) func create_lobby(): var lobby := preload("res://server/lobby.tscn").instantiate() lobby.port = next_port_num next_port_num += 1 %Lobbies.add_child(lobby) %LobbyList.add.rpc(external_address, lobby.port) func _on_create_lobby_pressed(): create_lobby()