freeftf/scripts/create.gd
patrick_pluto 699320353a Milestone 7 Beta 1
Redid the entire serverside and clientside, matchmaking is finally out, bugfixes.
2024-08-08 21:49:24 +02:00

58 lines
2 KiB
GDScript

## freeftf
## Copyright (C) 2024 Patrick_Pluto
##
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
extends Control
var elevated = false
var done
func _ready():
multiplayer.connected_to_server.connect(_on_connected_ok)
func server_prepare():
if Game.is_server:
$player_customization/ip.hide()
$player_customization/ip.text = "localhost"
$player_customization/ip.editable = false
$start/start.show()
$start/start.disabled = false
$player_list/list.text = " "
func _process(_delta):
server_prepare()
done = 0
for id in Game.player_list:
if done == 1:
$player_list/list.text = str($player_list/list.text +"\n" + Game.player_list[id])
else:
$player_list/list.text = Game.player_list[id]
done = 1
func _on_start_pressed():
for id in Game.player_list:
Client.rpc_id(id,"start_game")
func _input(_event):
if Input.is_action_just_pressed("escape"):
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
func _on_join_pressed():
if $player_customization/name.text != "" and $player_customization/name.text.length() <= 20 and $player_customization/ip.text != "":
Game.room_name = $player_customization/ip.text
Game.player_name = $player_customization/name.text
Client.join_game()
func _on_connected_ok():
$player_customization/join.hide()
$player_customization/join.disabled = true
$player_customization/name.editable = false
$player_customization/ip.editable = false