CORE/coreinit.gd
JeremyStarTM b57d00e9cd Many improvements (see commit description)
Added more things to roadmap, removed autoload singleton check, added support for Godot 4.1, all startup messages now use Logger.diag() instead of Logger.info() (making them disappear but can be shown if needed), removed autoload.gd, fixes syntax.
2023-07-07 10:58:49 +02:00

46 lines
1.9 KiB
GDScript

# coreinit.gd
# CORE Initializer
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends Node
@onready
var engine_version = Engine.get_version_info()
func _ready() -> void:
print("coreinit -> Checking CORE requirements")
if engine_version["major"] != 4:
print("coreinit -> CORE only supports Godot 4. Please upgrade/downgrade your Godot Project to Godot 4.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(141)
return
if engine_version["minor"] != 0 and engine_version["minor"] != 1:
print("coreinit -> CORE only supports Godot 4.0 and 4.1. Please upgrade/downgrade your Godot Project to Godot 4.0 or 4.1.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(142)
return
if engine_version["status"] != "stable":
print("coreinit -> CORE only supports stable Godot 4 releases. Please upgrade/downgrade your Godot Project to Godot 4.0.stable.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(143)
return
if get_node_or_null(NodePath("/root/Logger")) == null:
print("coreinit -> The CORE logger is missing in your autoload project settings! Please retry installing CORE.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(144)
return
if get_node_or_null(NodePath("/root/Preprocessor")) == null:
print("coreinit -> The CORE preprocessor is missing in your autoload project settings! Please retry installing CORE.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(145)
return
print("coreinit -> Constructing coreloader")
var coreloader = Control.new()
coreloader.name = "coreloader"
coreloader.set_script(ResourceLoader.load("res://CORE/coreloader.gd"))
print("coreinit -> Injecting coreloader")
get_tree().root.add_child.call_deferred(coreloader)
print("coreinit -> Switching to COREBackground")
get_tree().change_scene_to_packed(ResourceLoader.load("res://CORE/background.tscn"))