hotel-madness/scripts/ui/lobby.gd

16 lines
604 B
GDScript

extends Control
var label: PackedScene = preload("res://scenes/ui/elements/name_label.tscn")
func _ready() -> void:
if Networking.playerlist_changed.connect(_on_playerlist_changed) != OK:
Log.error("FAILED to connect the playerlist_changed signal to _on_playerlist_changed!", "Internal Error: Failed to connect signal.")
_on_playerlist_changed()
func _on_playerlist_changed() -> void:
for child: Label in $NameContainer.get_children():
child.free()
for peer: String in Networking.peers:
var instance: Label = label.instantiate()
instance.text = peer
$NameContainer.add_child(instance)