CORE/autoload.gd

32 lines
871 B
GDScript3
Raw Normal View History

# autoload.gd
# CORE Autoloader
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends Node
@onready
var core = get_node(NodePath("/root/core"))
func singleton(singleton_name:String,singleton_path:String) -> void:
var node = Control.new()
node.name = singleton_name
node.set_script(ResourceLoader.load(singleton_path))
get_tree().root.add_child(node)
func preset(plugin_id:String) -> bool:
var node = Control.new()
match(plugin_id):
"dialogmgr":
node.name = "DialogueManager"
node.set_script(ResourceLoader.load("res://addons/dialogue_manager/dialogue_manager.gd"))
_:
Logger.error("autoload","Failed adding preset \"" + plugin_id + "\": Invalid preset.")
return false
get_tree().root.add_child(node)
return true
func _ready() -> void:
core.setready()