Standardized for Godot 4

This commit is contained in:
Paul Black 2023-02-14 13:29:43 -07:00
parent 6b0d3d1c68
commit 06f8180169

View file

@ -2,11 +2,12 @@ extends Node
var peer:= ENetMultiplayerPeer.new()
func peer_connected(pid: int):
print("Peer connected: ", pid)
func _on_peer_connected(id: int):
print("Peer connected: ", id)
# add your code here to handle the successful connection
func peer_disconnected(pid: int):
print("Peer disconnected: ", pid)
func _on_peer_disconnected(id: int):
print("Peer disconnected: ", id)
func _ready():
pass
@ -41,8 +42,8 @@ func _on_join_button_pressed():
else:
$errorLabel.text = "ERROR: NO PORT SPECIFIED"
return
peer.connect(&"peer_connected", peer_connected)
peer.connect(&"peer_disconnected", peer_disconnected)
peer.connect(&"peer_connected", _on_peer_connected)
peer.connect(&"peer_disconnected", _on_peer_disconnected)
var result = peer.create_client(IPADD, intPORT)
var resultString = str(result)
$errorLabel.text = resultString
@ -54,3 +55,4 @@ func _on_join_button_pressed():
print("Connected to server at IP ", IPADD, ":", intPORT, "!")
$errorLabel.text = "Connected to server!"