Added auto host option and server scene to automatically start server through CLI

remotes/1711838515240372319/tmp_refs/heads/godot4-port
Jan 2020-09-21 17:01:39 +02:00
parent 1ba9acb790
commit 2a0a7f19ff
3 changed files with 16 additions and 5 deletions

14
Game.gd
View File

@ -1,9 +1,10 @@
extends Node
export var SERVER_PORT = 9999 setget , get_port
export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" setget , get_ip
export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" setget , get_ip
export var MAX_PLAYERS = 10
export (String, "MENU", "PLAYING") var GAME_MODE = "MENU"
export var auto_host = false
var mouse_sensitivity_multiplier = 1.0
@ -20,6 +21,10 @@ func _ready():
$MenuContainer/MainMenu/Destination/Port.set_text(str(SERVER_PORT))
load_settings()
if auto_host:
initialize_server(false)
print("qwueyhgfiuyqwgaadsf")
func load_settings():
var load_settings = File.new()
@ -71,9 +76,10 @@ func open_menus():
$MenuContainer.show()
func close_menus():
GAME_MODE = "PLAYING"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
$MenuContainer.hide()
if has_node("MenuContainer"):
GAME_MODE = "PLAYING"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
$MenuContainer.hide()
func return_to_menu(type):
for menu in $MenuContainer.get_children():

View File

@ -36,7 +36,6 @@ environment = SubResource( 2 )
[node name="Level" parent="." instance=ExtResource( 3 )]
[node name="Players" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 12.6315, 8.00684, -4.99273 )
[node name="MenuContainer" type="CenterContainer" parent="."]
anchor_right = 1.0

6
Server.tscn Normal file
View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Game.tscn" type="PackedScene" id=2]
[node name="Game" instance=ExtResource( 2 )]
auto_host = true