Standardized for Godot 4
This commit is contained in:
parent
6b0d3d1c68
commit
06f8180169
1 changed files with 9 additions and 7 deletions
|
@ -2,11 +2,12 @@ extends Node
|
||||||
|
|
||||||
var peer:= ENetMultiplayerPeer.new()
|
var peer:= ENetMultiplayerPeer.new()
|
||||||
|
|
||||||
func peer_connected(pid: int):
|
func _on_peer_connected(id: int):
|
||||||
print("Peer connected: ", pid)
|
print("Peer connected: ", id)
|
||||||
|
# add your code here to handle the successful connection
|
||||||
|
|
||||||
func peer_disconnected(pid: int):
|
func _on_peer_disconnected(id: int):
|
||||||
print("Peer disconnected: ", pid)
|
print("Peer disconnected: ", id)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
|
@ -41,8 +42,8 @@ func _on_join_button_pressed():
|
||||||
else:
|
else:
|
||||||
$errorLabel.text = "ERROR: NO PORT SPECIFIED"
|
$errorLabel.text = "ERROR: NO PORT SPECIFIED"
|
||||||
return
|
return
|
||||||
peer.connect(&"peer_connected", peer_connected)
|
peer.connect(&"peer_connected", _on_peer_connected)
|
||||||
peer.connect(&"peer_disconnected", peer_disconnected)
|
peer.connect(&"peer_disconnected", _on_peer_disconnected)
|
||||||
var result = peer.create_client(IPADD, intPORT)
|
var result = peer.create_client(IPADD, intPORT)
|
||||||
var resultString = str(result)
|
var resultString = str(result)
|
||||||
$errorLabel.text = resultString
|
$errorLabel.text = resultString
|
||||||
|
@ -54,3 +55,4 @@ func _on_join_button_pressed():
|
||||||
print("Connected to server at IP ", IPADD, ":", intPORT, "!")
|
print("Connected to server at IP ", IPADD, ":", intPORT, "!")
|
||||||
$errorLabel.text = "Connected to server!"
|
$errorLabel.text = "Connected to server!"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue