grounders-slowjam-2024/server/lobby_list.gd

22 lines
665 B
GDScript3
Raw Normal View History

2024-05-25 17:15:59 -06:00
extends Control
signal join_lobby(addr: String, port: int)
@rpc("reliable", "authority", "call_local")
2024-05-31 16:47:56 -06:00
func add(port: int):
2024-05-25 17:15:59 -06:00
var lobby_button := preload("res://server/lobby_list_entry.tscn").instantiate()
2024-05-31 16:47:56 -06:00
var addr := "127.0.0.1"
2024-05-31 21:59:49 -06:00
if not multiplayer.is_server():
var peer := (multiplayer.multiplayer_peer as ENetMultiplayerPeer).get_peer(1)
2024-05-31 16:47:56 -06:00
addr = peer.get_remote_address()
2024-05-25 17:15:59 -06:00
lobby_button.address = addr
lobby_button.port = port
$Lobbies.add_child(lobby_button, true)
lobby_button.pressed.connect(emit_join_lobby.bind(addr, port))
func emit_join_lobby(addr: String, port: int):
join_lobby.emit(addr, port)
func lobbies():
return $Lobbies.get_children()