Make register_custom_module() less verbose
This commit is contained in:
parent
8f29bc5e99
commit
94a677286c
1 changed files with 15 additions and 8 deletions
23
src/core.gd
23
src/core.gd
|
@ -245,19 +245,26 @@ func register_custom_module(module_name: String, module_origin: String, module_c
|
||||||
if custom_modules.has(module_name):
|
if custom_modules.has(module_name):
|
||||||
loggeri.error(stringify_variables("Registering module failed: A custom module with the name %name% already exists.", { "name": module_name }))
|
loggeri.error(stringify_variables("Registering module failed: A custom module with the name %name% already exists.", { "name": module_name }))
|
||||||
return false
|
return false
|
||||||
loggeri.diag("Updating variables")
|
|
||||||
|
# Update variables
|
||||||
module_class.name = module_name
|
module_class.name = module_name
|
||||||
module_class.core = self
|
module_class.core = self
|
||||||
module_class.logger = logger.get_instance(module_origin, module_class)
|
module_class.logger = logger.get_instance(module_origin, module_class)
|
||||||
module_class.logger.framework = true
|
module_class.logger.framework = true
|
||||||
loggeri.diag("Adding module to SceneTree")
|
|
||||||
custom_modules_node.add_child(module_class)
|
# Register module
|
||||||
loggeri.diag("Merging module with custom_modules")
|
|
||||||
custom_modules.merge({ module_name: module_class })
|
custom_modules.merge({ module_name: module_class })
|
||||||
loggeri.diag("Initializing custom module")
|
|
||||||
module_class._initialize()
|
# Add to 'custom_modules_node'
|
||||||
loggeri.diag("Updating custom module configuration")
|
custom_modules_node.add_child(module_class)
|
||||||
module_class._pull_config()
|
|
||||||
|
# Initialize module
|
||||||
|
@warning_ignore("redundant_await")
|
||||||
|
await module_class._initialize()
|
||||||
|
|
||||||
|
# Update module configuration
|
||||||
|
@warning_ignore("redundant_await")
|
||||||
|
await module_class._pull_config()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
## Unregisters a custom module, making it no longer available.
|
## Unregisters a custom module, making it no longer available.
|
||||||
|
|
Loading…
Reference in a new issue