project_teddy/scripts/host.gd
2023-02-21 12:53:13 -07:00

49 lines
1,014 B
GDScript

extends Node
var SCENE
func _ready():
pass
func _process(delta):
pass
func _on_close_pressed():
self.queue_free()
func _on_playground_pressed():
$mapSelected.text = "Playground"
SCENE = "res://scenes/playground.tscn"
func _on_start_button_pressed():
var PORT = $portBox.text
var MAX_PLAYERS = $playerBox.text
var intPORT = int(PORT)
var intMAX = int(MAX_PLAYERS)
if PORT:
prints("Player chose port:", intPORT)
if SCENE:
print("Player chose map: ", SCENE)
if MAX_PLAYERS:
if intMAX < 1:
$mapSelected.text = "MAX PLAYERS CANNOT BE NEGATIVE"
elif intMAX > 4095:
$mapSelected.text = "MAX PLAYERS CANNOT BE ABOVE 4095"
else:
print("Player chose player limit: ", intMAX)
Networking.create_server(intPORT, intMAX)
Networking.load_map(SCENE)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
$mapSelected.text = "NO MAX PLAYERS SELECTED"
else:
$mapSelected.text = "NO MAP SELECTED"
else:
$mapSelected.text = "NO PORT SPECIFIED"