Getters functions

GetDisplayResolution()

Returns the width and height (respectively) of the game window in pixels.

Definition

GetDisplayResolution() -> float, float

Usage example

init.lua
width, height = GetDisplayResolution()
print(width, height)
<console>
> 1920 1080

GetMod()

Returns the return value of the mod with the given name.

Definition

GetMod(modName: string) -> object

Usage example

init.lua
mod = GetMod('MyMod')

GetSingleton()

Returns the singleton for the given type name if it exists, otherwisenil.

A singleton is the sole instance of a type, often used for global operations.

Definition

Usage example

GetVersion()

Returns the current CET build's commit hash.

Definition

Usage example

ModArchiveExists()

Returns whether the specified .archive file is present in the archive/pc/mod folder

Definition

Usage example

Detect a Redscript mod

This technique can be used to detect whether your Redscript mod is present, from CET side. It can be useful if you are writing a mod with both languages for some reason.

You can declare a static method without a body. It will do nothing:

You can now test whether this method is defined from CET side using this:

You can call IsRedscriptDetected() and it will return true when your Redscript method is detected (meaning your Redscript mod is loaded) or false otherwise.

Don't forget to change NameOfYourMod in both cases.

If you're using redscript modules, and your IsDetected function is inside a module, the name will be mangled to include the full module name and a dot separating it:

Last updated