Add a map-loader sctipt
This commit is contained in:
@ -23,6 +23,14 @@ func _ready() -> void:
|
||||
multiplayer.connected_to_server.connect(_on_connected_ok)
|
||||
multiplayer.connection_failed.connect(_on_connected_fail)
|
||||
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||
|
||||
var map_dir := DirAccess.open("res://scenes/maps/maps/")
|
||||
if map_dir:
|
||||
map_dir.list_dir_begin()
|
||||
var file_name = map_dir.get_next()
|
||||
while file_name != "":
|
||||
$Maps.add_item(file_name)
|
||||
file_name = map_dir.get_next()
|
||||
|
||||
func join_game(address = ""):
|
||||
address = address_input.text
|
||||
@ -50,7 +58,12 @@ func remove_multiplayer_peer():
|
||||
# do Lobby.load_game.rpc(filepath)
|
||||
@rpc("call_local", "reliable")
|
||||
func load_game():
|
||||
get_tree().change_scene_to_file("res://scenes/maps/el_test.tscn")
|
||||
var chosen_map_index = $Maps.get_selected_items()[0]
|
||||
var chosen_map = $Maps.get_item_text(chosen_map_index)
|
||||
print(chosen_map)
|
||||
var path_tmpl := "res://scenes/maps/maps/%s"
|
||||
var path := path_tmpl % chosen_map
|
||||
get_tree().change_scene_to_file(path)
|
||||
|
||||
# Every peer will call this when they have loaded the game scene.
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
|
Reference in New Issue
Block a user