# Mod Structure

## Summary

This page will tell you how the CET mod folder structure works. To download a ready-to-go example project, check the wiki's [github repo](https://github.com/CDPR-Modding-Documentation/Cyberpunk-Modding-Docs/tree/main/_example_mods_and_templates/cyber_engine_tweaks).

## Setting up the folder

{% hint style="info" %}
Cyber Engine Tweaks will be looking for mods inside its`/mods/` folder, with each mod having it's own subfolder.
{% endhint %}

Create a new folder in the `<`[`cet_path`](#user-content-fn-1)[^1]`>/mods/` folder to get started, e.g. `my_mod` (snake case recommended)

```
Cyberpunk 2077/
├─ bin/
│  ├─ x64/
│  │  ├─ plugins/
│  │  │  ├─ cyber_engine_tweaks/
│  │  │  │  ├─ mods/
│  │  │  │  │  ├─ mod_1/
│  │  │  │  │  ├─ mod_2/
│  │  │  │  │  ├─ mod_3/
│  │  │  │  │  ├─ my_mod/ <- here
```

## Setting up `init.lua` file

CET will be looking for an `init.lua` file inside your mod folder. This is the entry point of your mod, and gets executed when the game is launched.

```
../
├─ cyber_engine_tweaks/
│  ├─ mods/
│  │  ├─ my_mod/
│  │  │  ├─ init.lua
```

{% hint style="info" %}
Each mod only has read / write access to its own subfolder, so any extra files need to be placed in the same folder or a subfolder.
{% endhint %}

## Firing up the code

The `init.lua` file is the only file that gets automatically loaded, thus should contain all your initialization code.

Start by printing simple info into the [CET Console](/cyber-engine-tweaks/console/console.md) using the [print()](/cyber-engine-tweaks/cet-functions/misc/debug-functions.md#print) function. Then register a listener on the [onInit](/cyber-engine-tweaks/cet-functions/events/oninit.md) event, and print something else.

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

```lua
-- mod info
mod = {
    ready = false
}

-- print on load
print('My Mod is loaded!')

-- onInit event
registerForEvent('onInit', function() 
    
    -- set as ready
    mod.ready = true
    
    -- print on initialize
    print('My Mod is initialized!')
    
end)

-- return mod info 
-- for communication between mods
return mod
```

{% endcode %}

Launch the game, and open the [CET Console](/cyber-engine-tweaks/console/console.md). You should see your printed text.

{% hint style="info" %}
Learn more about [Events here](/cyber-engine-tweaks/cet-functions/events.md). It is an important concept to assimilate for your future mod.
{% endhint %}

{% hint style="info" %}
For communication between mods, use the [GetMod()](/cyber-engine-tweaks/cet-functions/misc/getters-functions.md#getmod) function.
{% endhint %}

{% hint style="info" %}
Tips: Press the "Reload All Mods" button on the [CET Overlay](/cyber-engine-tweaks/console/usage.md) after making changes to your mod files to see the effect in live.
{% endhint %}

## Creating mods

* To now actually create a complex mod, you'll want to interact with the game's system, modify and create instances of game classes and modify the game's code. For that, head to the [Scripting API ](broken://pages/TOat5YCsYTM416xAxJaY)section
* Additionally read up on the CET Functions, for information on how to create custom keybinds, Observer and Override game functions, spawn objects and more

{% file src="/files/-MPB939a4jS4lxMnv20z" %}
Result of Dump
{% endfile %}

[^1]: The directory where Cyber Engine Tweaks is installed.

    Usually: C:/Program Files (x86)/Steam/steamapps/common/Cyberpunk 2077/bin/x64/plugins/cyber\_engine\_tweaks


---

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

```
GET https://wiki.redmodding.org/cyber-engine-tweaks/first-steps/mod-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
