Rename world_control Fix package name Attempt with main package Go world_control debug Go world_control debug Added get world RPC method Remove '_' from module Nakama plugin testing Nakama plugin testing Nakama plugin testing Try updated pipeline Nakama plugin testing Update pipeline Rework plugin dir Fix path Fix imports Fix imports Load match Load match work Server changes Server changes Server changes Changes basic upon helpful suggestions Client side get match
49 lines
1.4 KiB
GDScript
49 lines
1.4 KiB
GDScript
extends Node
|
|
|
|
export(NodePath) var usernamePath
|
|
export(NodePath) var passwordPath
|
|
export(NodePath) var buttonPath
|
|
export(NodePath) var errorPath
|
|
|
|
var usernameEdit : LineEdit
|
|
var passwordEdit : LineEdit
|
|
var errorLabel : Label
|
|
var button : Button
|
|
|
|
func _ready():
|
|
# Get nodes
|
|
usernameEdit = get_node(usernamePath)
|
|
passwordEdit = get_node(passwordPath)
|
|
errorLabel = get_node(errorPath)
|
|
button = get_node(buttonPath)
|
|
|
|
# Connect submission button
|
|
button.connect("button_down", self, "login")
|
|
usernameEdit.connect("text_entered", self, "login")
|
|
passwordEdit.connect("text_entered", self, "login")
|
|
|
|
# Clear error message
|
|
errorLabel.text = ""
|
|
|
|
func login(_text=""):
|
|
var error : NakamaException = yield(ServerConnection.authenticate_async(usernameEdit.text, passwordEdit.text), "completed")
|
|
|
|
# Check for error
|
|
if error:
|
|
passwordEdit.text = ""
|
|
display_message(error.message)
|
|
else:
|
|
display_message("Logged in successfully!", Color.green)
|
|
display_message("Connecting to server...", Color.gray)
|
|
error = yield(ServerConnection.connect_to_server_async(), "completed")
|
|
if error:
|
|
display_message(error.message)
|
|
else:
|
|
display_message("Connected to server!", Color.green)
|
|
yield(ServerConnection.join_world_async(), "completed")
|
|
|
|
func display_message(message="", color=Color.red):
|
|
errorLabel.add_color_override("font_color", color)
|
|
errorLabel.text = message
|
|
print(message)
|