> 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/cyber-engine-tweaks/first-steps/mod-structure.md).

# Mod Structure

Explaining how to create and run a custom mod

## 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](https://wiki.redmodding.org/cyber-engine-tweaks/console/console) using the [print()](/scripting-cyberpunk/cyber-engine-tweaks/cet-functions/misc/debug-functions.md#print) function. Then register a listener on the [onInit](/scripting-cyberpunk/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](https://wiki.redmodding.org/cyber-engine-tweaks/console/console). You should see your printed text.

{% hint style="info" %}
Learn more about [Events here](/scripting-cyberpunk/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()](/scripting-cyberpunk/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](https://wiki.redmodding.org/cyber-engine-tweaks/console/usage) 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 ](/scripting-cyberpunk/cyber-engine-tweaks/common-patterns/scripting-api.md)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
