Changed openMap function to check if it's a string instead of just doing it

This commit is contained in:
2024-08-15 02:04:24 -05:00
parent 95fc1ccbce
commit a399619b9a

View File

@ -2,22 +2,22 @@ class_name MapLoader
extends Node3D
@export var Default_Map:PackedScene
@export var scenes: Array[PackedScene]
signal map_loaded
var current_map
func openMap(path=GlobalSettings.current_map):
if path is PackedScene:
current_map = path.instantiate()
else:
current_map = load(path).instantiate()
func openMap(new_map=GlobalSettings.current_map):
if new_map is PackedScene:
current_map = new_map.instantiate()
if new_map is String:
current_map = load(new_map).instantiate()
add_child(current_map)
emit_signal("map_loaded")
func closeMap():
remove_child(current_map)
func _init():
openMap()
openMap()