> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/scripting-cyberpunk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/scripting-cyberpunk/scripting/redscript-to-cet.md).

# 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](/scripting-cyberpunk/redscript/language-reference/structure-names.md) 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:

```swift
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:

```lua
print(MySystem.GetInstance())
MySystem.GetInstance():InstanceMethod()
MySystem.StaticMethod()

print(MyEnum.First)
```

### Modules

As mentioned in the page for [full qualified names](/scripting-cyberpunk/redscript/language-reference/structure-names.md), 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 `_`.

```swift
module MyMod.Core

public class MySystem extends ScriptableSystem {
  // ...

  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;
  }
}
```

```lua
MyMod_Core_MySystem.StaticMethod()
```
