25 lines
570 B
GDScript
25 lines
570 B
GDScript
extends Node
|
|
|
|
@onready var scene_root = $/root/Game/CurrentScene
|
|
var current_world : Node = null
|
|
|
|
func get_world() -> String:
|
|
return current_world.scene_file_path
|
|
|
|
func set_world(path: String):
|
|
if ResourceLoader.exists(path):
|
|
var world = load(path).instantiate()
|
|
scene_root.add_child(world)
|
|
current_world = world
|
|
else:
|
|
printerr("Level %s does not exist" % path)
|
|
|
|
func remove_world():
|
|
var world = scene_root.get_child(0)
|
|
if world == null:
|
|
printerr("No world node found")
|
|
return
|
|
|
|
scene_root.remove_child(world)
|
|
world.queue_free()
|
|
current_world = null
|