diff --git a/Scenes/RootNode.tscn b/Scenes/RootNode.tscn index e752e34..81b6d95 100644 --- a/Scenes/RootNode.tscn +++ b/Scenes/RootNode.tscn @@ -4,3 +4,11 @@ [node name="RootNode" type="Node"] script = ExtResource( 1 ) + +[node name="ConsoleOutput" type="TextEdit" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +readonly = true +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/Scripts/RootNode.gd b/Scripts/RootNode.gd index 3243705..a36f7c4 100644 --- a/Scripts/RootNode.gd +++ b/Scripts/RootNode.gd @@ -5,6 +5,7 @@ const MAX_PLAYERS : int = 2 const PORT : int = 9374 var ids = [] +var console_output : TextEdit = null func _ready() -> void: var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new() @@ -13,17 +14,24 @@ func _ready() -> void: get_tree().connect("network_peer_connected", self, "_peer_connected") get_tree().connect("network_peer_disconnected", self, "_peer_disconnected") + + console_output = $ConsoleOutput + +func console_print(text : String) -> void: + console_output.text += "\n" + text + console_output.cursor_set_line(console_output.get_line_count()) + print(text) func _peer_connected(id : int) -> void: if not id: return ids.append(id) - print("Player has connected with id " + String(id)) + self.console_print("Player has connected with id " + String(id)) # TODO: When we reach max players -> start the game func _peer_disconnected(id : int) -> void: ids.erase(id) - print("Player has disconnected with id " + String(id)) + self.console_print("Player has disconnected with id " + String(id)) # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta):