This repository has been archived on 2022-01-09. You can view files and clone it, but cannot push or open issues/pull-requests.
liblast/GUI/CharacterSelect.gd

28 lines
762 B
GDScript
Raw Permalink Normal View History

2020-10-14 00:45:11 +02:00
extends Control
2020-12-10 00:26:43 +01:00
onready var game = get_parent().get_parent()
func _ready():
var dir = Directory.new()
dir.open("res://Assets/Characters/")
dir.list_dir_begin()
2020-12-10 00:26:43 +01:00
var file = dir.get_next()
while file != "":
if not file.begins_with("."):
# Add character
add_character(file)
file = dir.get_next()
func add_character(character_name):
var path = "res://Assets/Characters/" + character_name + "/" + character_name + ".tscn"
var packed_character = load(path)
var character_option = preload("res://GUI/CharacterOption.tscn").instance()
$CenterContainer/VBoxContainer/CharacterList.add_child(character_option)
character_option.set_character(packed_character)
2020-12-10 00:26:43 +01:00
2020-10-14 00:45:11 +02:00
func spawn():
get_parent().get_parent().spawn(get_tree().get_network_unique_id())