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.

Setting up the folder

Cyber Engine Tweaks will be looking for mods inside its/mods/ folder, with each mod having it's own subfolder.

Create a new folder in the <>/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

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.

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 using the print() function. Then register a listener on the onInit event, and print something else.

init.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

Launch the game, and open the CET Console. You should see your printed text.

Learn more about Events here. It is an important concept to assimilate for your future mod.

For communication between mods, use the GetMod() function.

Tips: Press the "Reload All Mods" button on the CET Overlay after making changes to your mod files to see the effect in live.

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

Last updated