Skip to main content

Initializing CORE

Before you can use the CORE Framework, you'll need to initialize it.

This example should explain everything:

extends Node

var core: Core
## Gets a so called "logger instance". It basically saves you an argument on each log call.
@onready var logger: CoreLoggerInstance = core.logger.get_instance("path/to/script.gd", self)

# Preinitialization phase
func _init() -> void:
# Create new CoreConfiguration
var config: CoreConfiguration = CoreConfiguration.new()
# Allow diagnostic and verbose messages
config.logger_level = CoreTypes.LoggerLevel.DIAG
# Initialize CORE with custom configuration
core = await Core.new(config)
# Initialize CORE with standard configuration, commented out
#core = await Core.new()

# Initialization phase
func _ready() -> void:
# Initialize CORE completely
await get_tree().process_frame # to avoid "setting up nodes" error
get_tree().root.add_child(core) # add CORE Object to SceneTree
await core.complete_init() # wait for CORE to initialize completely

# >>> Your code should start executing here <<<<

# Print "Hello World!" to console with all possible 'LoggerLevel''s
for type in CoreTypes.LoggerLevel:
if type == "NONE": continue # Exclude "NONE" logger level
type = StringName(type.to_lower()) # Convert to StringName
logger.call(type, "Hello World!") # Call it

# Test crash
logger.crash("This is a test crash.")