REDScript To CET
How to access custom defined structures from Redscript in CET
Any custom structure you define in Redscript can also be accessed and referenced in CET, to reference it, you need the full qualified name of the structure. As mentioned in that guide, all structures have a fully qualified name such as MyMod.Core.MySystem, to reference a structure in CET you just need to take the qualified name and replace all . with _.
For example let's say we have the following stuff defined in Redscript:
public enum MyEnum {
First = 0,
Second = 1,
Third = 2
}
public class MySystem extends ScriptableSystem {
public func OnAttach() -> Void {
// ...
}
public func OnDetach() -> Void {
// ...
}
public func InstanceMethod() -> Void {
FTLog(s"hello from instance method");
}
public static func StaticMethod() -> Void {
FTLog(s"hello from static method");
}
public static final func GetInstance(gameInstance: GameInstance) -> ref<MySystem> {
return GameInstance.GetScriptableSystemsContainer(gameInstance).Get(NameOf<MySystem>()) as MySystem;
}
}Here's how you can access it from CET/Lua:
Modules
As mentioned in the page for full qualified names, the respective module is also specified in the qualified name, meaning you need to specify this when referencing it in CET.
Essentially, all . must be replaced with _.
Last updated