For the complete documentation index, see llms.txt. This page is also available as Markdown.

Structure Names

Any custom structure you define in scripts (such as a class or an enum) naturally has their respective name, but also has a respective fully qualified name which includes its full module path (if it was defined in one).

Simple Example

As an example, let's say we have defined a class as:

public class MySystem extends ScriptableSystem {
  // ...
}

The full qualified name for this structure would be n"MySystem".

Modules

When defining your structures in modules, the full module path is also included in the structure's qualified name. For example, if we defined the class above in the module MyMod.Core, it's qualified name would be n"MyMod.Core.MySystem".

module MyMod.Core

public class MySystem extends ScriptableSystem {
  //
}

NameOf<T>()

Redscript has a built-in function which can be used to get the qualified name for a structure:

Instead of manually specifying the qualified name (which may change throughout the process of creating and updating your mod, which would then need for all references to be updated), this function will resolve into the qualified name for the given structure.

As an example:

Usage

The fully qualified names for structures is needed as some systems require it to fulfill its purpose.

Such as registering an event listener, getting an instance of your scriptable with gameScriptableSystemsContainer#Get for ScriptableSystem or ScriptableServiceContainer#GetService for ScriptableService. These (and other methods and systems) require the full qualified name of your structure to work.

Instead of manually specifying n"MyMod.Core.MySystem", you can instead give NameOf<MySystem>() as the argument as the function will resolve into the qualified name for the system.

Last updated