ModScript
See the code atresources/mod_script.gd
Description
Inherits GDScript
The ModScript
class is an extension of the GDScript
class in the Godot game engine. It serves as a container for a script to be used as the Mod.instance_script
. When a ModScript
is created, it automatically registers the associated class to the ModClassDB
, saving the new RegisteredClass
.
Properties
registered_class
var registered_class: RegisteredClass
The associated RegisteredClass
of the script.
Type | RegisteredClass |
---|---|
Default | null |
Methods
_init
func _init(script: GDScript) -> void
Initializes the ModScript
with the provided GDScript
object. This method registers the script class to ModClassDB
and saves the resulting RegisteredClass
in the registered_class
variable.
This script also takes over the provided script
, by:
- Assigning the
script
's source code to theGDScript.source_code
property - Taking over the original path (see
Resource.take_over_path()
)
Parameters
script
(GDScript) The GDScript object associated with the ModScript
.
Returns
void
Note
This method registers the script class to the ModClassDB
and saves the resulting RegisteredClass
in the registered_class
variable. The script's source code is also assigned to the GDScript.source_code
property.