Getters functions
GetDisplayResolution()
Returns the width and height (respectively) of the game window in pixels.
Definition
GetDisplayResolution() -> float, float
Usage example
width, height = GetDisplayResolution()
print(width, height)
> 1920 1080
GetMod()
Returns the return value of the mod with the given name.
If you don't return anything in your init.lua
file, this function will return nil
. This will often look like return MyMod:new()
at the end of your file. See the Lua documentation for info about how classes can be implemented in Lua.
Definition
GetMod(modName: string) -> object
Usage example
mod = GetMod('MyMod')
-- any data returned by the mod
GetSingleton()
Returns the singleton for the given type name if it exists, otherwisenil
.
Definition
GetSingleton(singletonTypeName: string) -> SingletonReference | nil
Usage example
gameTime = GetSingleton("gameTimeSystem")
-- get time
gameTime:GetGameTime()
-- set time
gameTime:SetGameTimeByHMS(12, 0, 0) -- 12h0m0s
GameTime[ seconds:734466 ]
GetVersion()
Returns the current CET build's commit hash.
Definition
GetVersion() -> string
Usage example
version = GetVersion()
print(version)
> v1.27.1
ModArchiveExists()
Returns whether the specified .archive
file is present in the archive/pc/mod
folder
Definition
ModArchiveExists(archiveName: string) -> bool
Usage example
print(ModArchiveExists('myModFiles.archive'))
> true
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:
// Redscript side
public static func IsDetected_NameOfYourMod() -> Void {}
You can now test whether this method is defined from CET side using this:
-- CET side
function IsRedscriptDetected()
return Game["IsDetected_NameOfYourMod"] ~= nil
end
You can call IsRedscriptDetected()
and it will return true
when your Redscript method is detected (meaning your Redscript mod is loaded) or false otherwise.
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:
// Redscript side
module Module.Name
public static func IsDetected() -> Void {}
-- CET side
function IsRedscriptDetected()
return Module_Name_IsDetected ~= nil
-- equivalent syntax without conversion:
-- return Game["Module.Name.IsDetected"] ~= nil
end
Last updated