> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/cyber-engine-tweaks/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/cyber-engine-tweaks/cet-functions/misc/getters-functions.md).

# Getters functions

## GetDisplayResolution()

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

#### Definition

```swift
GetDisplayResolution() -> float, float
```

#### Usage example

{% code title="init.lua" %}

```lua
width, height = GetDisplayResolution()
print(width, height)
```

{% endcode %}

{% code title="<console>" %}

```
> 1920 1080
```

{% endcode %}

## GetMod()

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

{% hint style="warning" %}
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](https://www.lua.org/pil/16.1.html) for info about how classes can be implemented in Lua.
{% endhint %}

#### Definition

```swift
GetMod(modName: string) -> object
```

#### Usage example

{% code title="init.lua" %}

```lua
mod = GetMod('MyMod')
```

{% endcode %}

{% code title="returns" %}

```lua
-- any data returned by the mod
```

{% endcode %}

## GetSingleton()

Returns the singleton for the given type name if it exists, otherwise`nil`.

{% hint style="info" %}
A singleton is the sole instance of a type, often used for global operations.
{% endhint %}

#### Definition

```swift
GetSingleton(singletonTypeName: string) -> SingletonReference | nil
```

#### Usage example

{% code title="init.lua" %}

```lua
gameTime = GetSingleton("gameTimeSystem")

-- get time
gameTime:GetGameTime()

-- set time
gameTime:SetGameTimeByHMS(12, 0, 0) -- 12h0m0s
```

{% endcode %}

{% code title="returns" %}

```
GameTime[ seconds:734466 ]
```

{% endcode %}

## GetVersion()

Returns the current CET build's commit hash.

#### Definition

```swift
GetVersion() -> string
```

#### Usage example

{% code title="init.lua" %}

```lua
version = GetVersion()

print(version)
```

{% endcode %}

{% code title="<console>" %}

```
> v1.27.1
```

{% endcode %}

## ModArchiveExists()

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

#### Definition

```swift
ModArchiveExists(archiveName: string) -> bool
```

#### Usage example

{% code title="init.lua" %}

```lua
print(ModArchiveExists('myModFiles.archive'))
```

{% endcode %}

{% code title="<console>" %}

```
> true
```

{% endcode %}

## 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:

<pre class="language-swift"><code class="lang-swift">// Redscript side
<strong>public static func IsDetected_NameOfYourMod() -> Void {}
</strong></code></pre>

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

```lua
-- 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.

{% hint style="info" %}
Don't forget to change `NameOfYourMod` in both cases.
{% endhint %}

If you're using redscript [modules](https://wiki.redmodding.org/redscript/language/language-features/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:

```swift
// Redscript side
module Module.Name
public static func IsDetected() -> Void {}
```

```lua
-- CET side
function IsRedscriptDetected()
  return Module_Name_IsDetected ~= nil
  -- equivalent syntax without conversion:
  -- return Game["Module.Name.IsDetected"] ~= nil
end
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.redmodding.org/cyber-engine-tweaks/cet-functions/misc/getters-functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
