This event gets triggered even before onInit, and can be useful for making changes to the TweakDB, as some values can only be changes very early during the loading process.
Miscellaneous
Miscellaneous functions useful for debugging and getting special objects and info.
Opposing to onInit, this event gets triggered whenever CET unloads all the mods, either due to the game shutting down, or when pressing the "Reload all mods" button in the CET Overlay.
Use this to do any clean-up work for your mod, e.g. despawning objects or removing status effects.
Guide to installing the Cyber Engine Tweaks into the game
Summary
This page tells you how to install Cyber Engine Tweaks - or you can check the 📺 Video Guide.
🔒 Prerequisites
Make sure Cyberpunk 2077 is updated to the latest version
Make sure you installed the latest
Make sure you run the game in Windowed Borderless
📋 Installation
Download the latest file. (Do not download the source code)
If using Windows, you should right click on the zip file, and check under Properties for a security notice saying "This file came from another computer and might be blocked to help protect this computer" - if that security notice is present, click the checkbox to unblock the contents of the zip file.
🎮 Launch the Game
When you first start the game, a window will appear prompting you to choose a keybind to bring up the . Pick any key and save it. It will open with that key from now on.
(Optional) To check that everything works you can look at the logs in <cyberpunk install path>/bin/x64/plugins/cyber_engine_tweaks/cyber_engine_tweaks.log
(Optional) When installing through Nexus Vortex, make sure to use hardlink deployment.
📺 Video Guide
What's next?
Game Log
How to use the Cyber Engine Tweaks Game Log
Game Log UI
This window shows any output done using Redscript's Log/LogChannel function, either coming from the games scripts themselves or from a Redscript mod.
Writing Logs
Observe, Override, NewProxy
Introduction
Cyber Engine Tweaks allow mods to listen or overwrite game's script functions/methods. There are three kinds of functions:
Observe allows to listen for function/method execution
allows to overwrite a function/method
allows to trigger a function/method callback using game's script system
Available Functions
Welcome
Welcome to Cyber Engine Tweaks official Wiki!
Cyber Engine Tweaks is a framework that allows modders to interact with the game's internal functions using . It also provides a user-interface with a console and additional tools to assist developers.
GETTING STARTED
For information on how to install Cyber Engine Tweaks, check out the link below.
Uninstall
How to remove Cyber Engine Tweaks
Remove the following folders/files:
<cyberpunk install path>
Usage
How to use the Cyber Engine Tweaks Overlay
What is the Overlay?
The Cyber Engine Tweaks Overlay is the interface that is used to display and set various settings, and configure mods hotkeys.
Additionally, the most advanced mods will also display their own settings window in this overlay. It contains different tabs:
Console
How to use the Cyber Engine Tweaks Console
Console UI
The console tab is where you type commands to use cheats and other useful functions.
FAQ
Frequently asked questions about Cyber Engine Tweaks based mods.
Clarification:
Bindings
How to use Cyber Engine Tweaks Bindings
Hotkeys
The Hotkeys tab is where you manage all the hotkeys of the mods you installed.
Settings
How to use Cyber Engine Tweaks Settings
Settings UI
The Settings tab is where you change the Overlay open/close hotkey, and toggle the tweaks to Cyberpunk2077's game engine.
TweakDB Editor
How to modify the TweakDB via CET
Summary
This page documents CET's in-game Tweak Editor.
Introduction
An overview of how to use CET to create custom mods
Preface
In the early days of Cyberpunk 2077 modding, we noticed a lack of discipline and proper use of the SDK provided by CET. So we strongly recommend you read the documentation and understand what is expected of you and your mods.
Events
Cyber Engine Tweaks has builtin events which can be listened using the registerForEvent() function. These listeners must be registered inside the init.lua file.
Keep in mind that CET events are not game events. For example, doesn't mean the game the initializing, but rather that CET loaded mods and the game's Scripting API.
If you need to listen for game events, take a look at the functions.
onInit
On onInit gets triggered once, when CET loads in all the mods. This event ensures that CET has fully loaded, and you have access to the Scripting API. There can be only one onInit event per mod.
Use it to register any , as well as do any one-off actions needed for your mod.
This event is a safe starting point for your code interaction with the game, as it guarantees the access to most of the Scripting API.
onUpdate
This event gets triggered on every frame that the game runs, thus is framerate dependent. The callback function gets the deltaTime passed along with it, which measures the frametime in ms, useful for making e.g. timers.
In here you can put any code that you want to run every frame, although it is best practice to only run your code when needed, e.g. using .
Use this event with caution, as it is triggered continuously once the game is launched.
RegisterHotkey
Hotkeys are buttons events triggered on key release. They must be registered using registerHotkey() at root level, outside of any event, in the init.lua file.
are not triggered while the player stay pressed on a game's keybind.
CET and Codeware
How to make the most of psiberx's script expansion framework
Documentation
stringType
Description of string type to use in functions
Reflexes
Strength
Utilities
A collection of LUA scripting utilities to make your life easier
Snippets & Examples
Ready-to-paste CET code
You can also find example mods
Game Functions
Overview of the different functions available to use on the console.
Special Types
Helper functions which let you construct internal data types.
/bin/x64/plugins/
<cyberpunk install path>/bin/x64/global.ini
<cyberpunk install path>/bin/x64/LICENSE
<cyberpunk install path>/bin/x64/version.dll
Notes
Removing Cyber Engine Tweaks will not undo any edits made to your character and your save files.
If you have added items to your inventory, you will not be able to remove them once you have removed this mod. Please ensure you have done so using the appropriate commands first.
Saves made with the patch should be completely fine without it, thought that might change once proper mods start coming out
"mod" or "mods" on this page refers to mods that are dependent on Cyber Engine Tweaks.
Cyber Engine Tweaks will be referred to as CET from now on.
I've installed this mod but nothing happens.
Make sure that CET works fine without any mods installed.
Make sure the mod that you are installing is compatible with the latest CET.
I've made sure the above are true but the mod still won't function.
You need to bind a hotkey in the Hotkeys tab of the CET overlay. Check how-to here.
I've bound the hotkeys but the hotkeys do nothing when I press it.
The hotkeys only work when the CET overlay is closed.
I've bound the hotkey and I've closed the CET overlay but still, nothing happens.
You need to press the hotkey combination in the right order.
For example Ctrl + Shift + S is different from Shift + Ctrl + S
I bound the hotkeys and the interface opens but I can't do anything there. There's no cursor in the window.
You need to open the CET overlay to interact with anything using your mouse.
This mod supports different languages, but when I change the language every character becomes a ? (question mark).
You need to change the default font of CET in order for the characters to show properly. You can follow this guide here.
Before you start, it is highly recommended to check out the Modding Resources page
If you are using VSCode, make sure to also pick up the CET VSCode extension
Next, it is recommended to read through the Scripts and Mod Structure page, which gives an overview on how to create a mod / run a single script. It also covers the basic elements of a mod
After that, you might want to check out the Scripting API page, which explains how you interact with the games systems and code.
Once you've made yourself familiar with how a general mod is structured and how to interact with the game, you might want to read up on the different functions offered by CET itself, such as Events, Keybinds, Overrides and more.
Check out the Examples section for a collection of small example mods and useful code snippets
As of Mar 2024, you can't access rRef or raRef natively via CET:
This will most likely return nil or crash the game.
Even if it does not, no reference is kept in memory: you're effectively working on a copy and there is currently no way to pass your changes back to the game.
Currently, the only way to access resources is via Codeware, which will do its best to sync your changes with the actually-existing object.
--
-- registerHotkey()
--
-- @param string slug The internal slug (must be unique in your mod scope)
-- @param string label The label displayed in CET Bindings
-- @param function callback The callback function
--
registerHotkey('slug', 'label', function()
-- hotkey is released
end)
-- this does not work
ComponentParser.GetMeshComponent(Game.GetPlayer(), 't0_000_pwa_fpp__torso')
Ensure all apps overlays are disabled as the console may not open: Steam, Discord, GOG, Geforce Experience, Windows 10 Game Bar, Rivatuner, Fraps, Afterburner etc...
You can now either
Unzip the download directly into your Cyberpunk 2077 game directory
or
Unzip to anywhere on your desktop. After unzipping the file, you will see a bin folder.
Drag the bin folder to your Cyberpunk 2077 game directory
If installed properly, the Cyber Engine Tweaks files will be in the <cyberpunk install path>/bin/x64 folder. As follow:
Everything you need to know to create your own mod for Cyber Engine Tweaks.
CONTRIBUTING
If you wish to contribute to the main repo, try to follow the coding style in the code, otherwise not much to say, don't use code that is not yours unless the license is compatible with MIT.
Upon the installation of CET, the overlay will appear automatically when you launch the game.
You need to assign a hotkey to it before you can move on:
Press the Hotkey button next to the Overlay Key.
Press a key or a key combination on your keyboard after the button becomes BINDING... to bind it.
Now the hotkey has been bound, you can press that key anytime to open/close the Overlay.
Asign a key for opening/closing the Overlay
CET does not allow mods to define default hotkeys. Thus, every time you install a new mod, you need to bind a hotkey for it, if it requires one.
Binding hotkeys for a mod is the same as how you bind the hotkey for the CET Overlay.
You can unbind a hotkey by pressing the UNBIND button behind it.
To save the changes, press the Save button.
Undefined hotkeys appear in red text. Unsaved changes appear in yellow text.
Bind/unbind hotkeys for mods
If you have encountered troubles when using a mod, please read this FAQ page:
For an introduction on TweakDB modding with CET, check the Simple Gameplay Mod guide
For further information, refer to the TweakDB section on this wiki
What is the TweakDB editor?
After opening CET with the key that you bound during the installation, you can find it in the "TweakDB Editor" tab. Here you can browse and update the TweakDatabase in real time.
Note that changes you made in the editor do not persist across game restarts.
Definition
Events Trigger Sequence
Here is a video showing when events are triggered in real-time:
You can find additional guides on how to install mods in the users section of the Cyberpunk 2077 modding wiki, including:
A for first-time users
... add perk points, level up, add money...?
For a list of console commands for beginners, check out the page:
... create my own mod?
You can find the api documentation under .
Checkout the page for your first steps:
... do $thing in code?
Check or , for example
Logs & Debug
Explaining where to find logs file and write them
Individual Mod Logs
On game launch, Cyber Engine Tweaks generates individual logs files in each mod folder, using their name. eg, <cet_path>/mods/my_mod/my_mod.log.
What it contains
This file contains all notices, errors and logs generated by the mod.
Write the file
You can write the log file using the functions.
Watch the file
You can use to watch files in live with a GUI, or use the following command line in the Windows Command shell:
CET Console Logs
Cyber Engine Tweaks has a global log file located in <cet_path>/scripting.log.
What it contains
This file contains all logs from the .
Write the file
You can write the log file by using the function.
Watch the file
You can use to watch files in live with a GUI, or use the following command line in the Windows Command shell:
Resources
A collection of helpful links and resources
Decompiled game scripts: These are the game's scripts decompiled to redscript. Extremely useful for understanding how functions work under the hood, game systems and classes interact with each other and what classes and functions are available. For more information on how to transpile redscript code to .lua code, read up on the Scripting API. Works best if downloaded and opened in some IDE like VSCode that lets you search across all files at once.
cp2077-cet-kit: psiberx's github repository with helper functions and scripts
: This is a database containing all the classes and their functions, their relation to each other, their functions, attributes and all the Enum's. Very useful for quickly looking up what functions a class offers and what parameters it takes. Also helpful for understanding which classes inherit from which. Nativedb has more types than decompiled scripts.
: A utility that helps you translating your CET mods, by lgomes_gvizstudio on github
: A collection of utility scripts, for tracking game states (In Game etc.), setting up timers and timed actions, storing data per game save and more.
: A collection of small example mods, such as controlling NPC AI, working with map pins, reading player inputs and more.
: Visual overview of the game's classes and structure. Very helpful for understanding the higher level structure.
: Discord server with multiple CET related channels, lots of more resources and snippets (Discord search is your best friend)
: An extensive tutorial covering how to work with the TweakDB, create a CET mod, override and observe functions and use redscript.
: An online sandbox to familiarize yourself with LUA and test some code without having to launch Cyberpunk with CET. Note that any CET/Game functions won't work in it.
onDraw
This event works similarly to onUpdate, except that it is used for drawing custom ImGui UI. It gets triggered on every frame that the game runs, thus is framerate dependent.
Use this event with caution, as it is triggered continuously once the game is launched.
Trying to draw ImGui UI outside this callback is prohibited
Usage Example
Render an ImGui window at anytime:
Advanced Example
Render an ImGui window when the player is sprinting:
This example use . Check the for further information on its usage.
onOverlayOpen
This event get triggered when the CET Overlay gets shown.
Use this to keep track of the overlays state, and e.g. to only draw your own UI when CETs overlay is visible. Use it in conjunction with onOverlayClose to get a proper on/off switch case.
Usage Example
Display a warning message when the is opened:
Advanced Example
Render an ImGui window when the is opened:
This example use the event, which is triggered continuously. Make sure to before any modification.
onOverlayClose
This event get triggered when the CET Overlay gets hidden.
Use this to keep track of the overlays state, and e.g. to only draw your own UI when CETs overlay is visible. Use it in conjunction with onOverlayOpen to get a proper on/off switch case.
Usage Example
Display a warning message when the is closed:
Advanced Example
Render an ImGui window when the is opened:
This example use the event, which is triggered continuously. Make sure to before any modification.
Async / waiting
Do stuff later without blocking
Summary
Published: Feb 18 2024 by
Last documented edit: Feb 18 2024 by
--
-- registerForEvent()
--
-- @param string event The event name
-- @param function callback The callback function
--
registerForEvent('event', function()
-- event is triggered
end)
registerForEvent('onDraw', function()
if ImGui.Begin('Window Title', ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text('Hello World!')
end
ImGui.End()
end)
init.lua
-- set initial switch
isSprinting = false
-- onInit
registerForEvent('onInit', function()
-- observe Sprint OnEnter state
Observe('SprintEvents', 'OnEnter', function(stateContext, scriptInterface)
isSprinting = true
end)
-- observe Sprint OnExit state
Observe('SprintEvents', 'OnExit', function(stateContext, scriptInterface)
isSprinting = false -- reset switch
end)
end)
-- onDraw
registerForEvent('onDraw', function()
-- bail early if not sprinting
if not isSprinting then
return
end
-- draw window
if ImGui.Begin('Notification', ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text('Nice sprint!')
end
ImGui.End()
end)
init.lua
-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
-- get player
local player = Game.GetPlayer()
-- bail early if player doesn't exists
if not player then
return
end
-- display warning message
player:SetWarningMessage('Overlay is open')
end)
init.lua
-- set initial var
local isOverlayVisible = false
-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
isOverlayVisible = true
end)
-- onOverlayClose
registerForEvent('onOverlayClose', function()
isOverlayVisible = false
end)
-- onDraw
-- this event is triggered continuously
registerForEvent('onDraw', function()
-- bail early if overlay is not open
if not isOverlayVisible then
return
end
-- draw ImGui window
if ImGui.Begin('Window Title', ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text('Hello World!')
end
ImGui.End()
end)
init.lua
-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
-- get player
local player = Game.GetPlayer()
-- bail early if player doesn't exists
if not player then
return
end
-- display warning message
player:SetWarningMessage('Overlay is closed')
end)
init.lua
-- set initial var
local isOverlayVisible = false
-- onOverlayOpen
registerForEvent('onOverlayOpen', function()
isOverlayVisible = true
end)
-- onOverlayClose
registerForEvent('onOverlayClose', function()
isOverlayVisible = false
end)
-- onDraw
-- this event is triggered continuously
registerForEvent('onDraw', function()
-- bail early if overlay is not open
if not isOverlayVisible then
return
end
-- draw ImGui window
if ImGui.Begin('Window Title', ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text('Hello World!')
end
ImGui.End()
end)
You can get Cron.lua from psiberx's cp2077-cet-kit on github. Add it to your sources, and then define it as a global:
How to use cron
Cron offers a bunch of functions for executing code later. The code you want to execute has to be inside a function (=> callback) and is passed among the arguments.
For periodically running functions, you need to include logic when to stop the execution.
Performance impact
To save processor load, it is best practice to define your callback outside of the function call. This can have a noticable performance impact, so you're gonna want to do this.
Good example:
The callback is defined once.
Bad example:
The callback is defined every time cron runs.
Passing function arguments
To pass arguments to your callback function, you pass them as arguments to cron:
Cron functions
Delay
Execute the callback after X seconds
Timer
Executes a function every X seconds.
The function will run forever unless you stop it!
Pausing and resuming a timer
You can pause a timer by passing its reference to cron:
🖥️
Overlay
🎹
Console
🖱️
Bindings
🛠️
Settings
🗄️
TweakDB Editor
⌛
Game Log
📖
Introduction
🎯
First Steps
💎
Resources
📘
CET Functions
📒
Game Functions
✏️
Snippets & Examples
Change font & language setting
A guide on how to change the font and font size for Cyber Engine Tweaks and mods based on Cyber Engine Tweaks. And how to display non-English characters.
Use a text editor to open the config file at <cet install path>/config.json to adjust the settings.
In this page, we use this example JSON snippet to guide you through adjusting the settings:
Change font
Locate this line under the "font" curly brace:
Add the path of the font you want to change to between the double-quotes.
For example, if you want to change the font to Comic Sans, just change this line into:
Note: You should use slash (/) instead of backslash (\) for the path.
How to display non-English characters
Some mods may have implemented multilingual support. But the non-English characters will display as a question mark "?". This is because the default font only contains .
To display a language that only uses ASCII characters (such as French, German), all you need to do is to change the font to one with a wider range (Literally any font).
To display a language that uses non-ASCII characters (such as Chinese, Russian), besides changing the font, you also need to change this line in the config file under the "font" curly brace:
Here is a table of the "language" options and their descriptions.
options
Descriptions
For example, to display Chinese all you need to do is:
The result (using the Sim Hei / 黑体 font):
VS Code
Features
Code completion for built-in Cyber Engine Tweaks, Dear ImGui and Cyberpunk 2077 types and functions (except sqlite)
Type resolving for Game.GetScriptableSystemsContainer():Get("Type"), NewObject("Type"), and GetSingleton("Type")
Contextual suggestions for default values and predefined sets
Installation
CET typedef
Download and extract the .
The lib files linked above is not the newest version.
You can join the and then visit to download the newest version (CET 1.27 / Patch 2.01 Typedefs).
Add next settings to the .vscode\settings.json or in the Settings GUI:
NOTE: ensure commas occur after every line
On first use it takes a couple of minutes to parse and cache all definitions. Unfortunately there is no visual indication of this process. When it's done the code assistance will be more responsive.
Dear ImGui typedef
To install the typedefs for Dear ImGui, you can manually download the files from GitHub repository and then follow the same installation process in to install them in VSCode.
Annotations
Callback parameters
You can specify the type of the parameters with @param annotation. It's very handy for Observe and Override:
Unresolved type
If type of some variable cannot be resolved or ambiguous you can force the type with @type annotation:
Generic functions
The type of the result of some functions depends on the parameters passed to the function. If a valid type name is passed as a parameter, then the resulting type must be resolved without custom annotations.
Getters functions
GetDisplayResolution()
Returns the width and height (respectively) of the game window in pixels.
Definition
Usage example
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 for info about how classes can be implemented in Lua.
Definition
Usage example
GetSingleton()
Returns the singleton for the given type name if it exists, otherwisenil.
A singleton is the sole instance of a type, often used for global operations.
Definition
Usage example
GetVersion()
Returns the current CET build's commit hash.
Definition
Usage example
ModArchiveExists()
Returns whether the specified .archive file is present in the archive/pc/mod folder
Definition
Usage example
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:
You can now test whether this method is defined from CET side using this:
You can call IsRedscriptDetected() and it will return true when your Redscript method is detected (meaning your Redscript mod is loaded) or false otherwise.
Don't forget to change NameOfYourMod in both cases.
If you're using redscript , and your IsDetected function is inside a module, the name will be mangled to include the full module name and a dot separating it:
AdjustTransformWithDurations
⚠️ All examples in this Observe/Override method ShootEvents.OnEnter to gain access to stateContext.
AdjustTransform
Base class for AdjustTransformWithDurations. Seems to do nothing if passed to adjustTransform scriptable parameter. Do not use: your movement will be blocked indefinitely until you reset adjustTransform.
AdjustTransformWithDurations
Discovered by void*
Request to change player trajectory (view angles) and/or player position.
This code has to be executed in the context where you have access to StateContext
for example:
Function has 3 types of behavior: set trajectory, set position or set both.
Changing player's trajectory to custom angles
This code will smoothly point your camera towards {0, 0, 0}.
How it looks in-game
Targeting an GameObject for trajectory
Does not change player's pitch.
Seems to target "nearest" targeting component (aka hitbox).
SetRotation is ignored if target is set.
This function seem to use TargetingSystem to find the "best component" and then calls a LookAt.
(Look at function and one)
How it looks in-game
Moving player
How it looks in-game
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 .
Scripting API
Explaining how to create and run a custom mod
To browse the API, do yourself a favour and use
Summary
RegisterInput
Inputs are buttons events that handle both key press and release states. They must be registered using registerInput() at root level, outside of any event, in the init.lua file.
The button state (press/release) is defined in the first argument passed to the callback.
Definition
TweakDB
Methods for interacting with TweakDB, the game's internal data store.
TweakDB is like the game’s database for gameplay features. It’s not actually code itself, but very large amounts of data structures, many of which link together, to make coherent gameplay elements.
TweakDB has two main elements: Flats, and Records Flats are just like a single piece of data, like a number, a string, a pointer to a record, etc. Records are like a collection of flats. Records have possible types, like a character record or a clothing record. The type of record determines what set of flats the record has.
An example of these gameplay features nearly entirely contained in TweakDB, would be the damaging quickhacks like Overheat, Contagion, and Short Circuit. The quickhack item to unlock them is in tweakdb, as well as the process of unlocking, making them show up on enemies, the uploading process, the status effect applied, all the special effects possible, as well as the stats to customize all of these things. Almost anything about these quickhacks can be changed in TweakDB.
NewProxy
NewProxy is a built-in CET feature you can use to declare callback functions. You can use it to bind a Lua function as a callback with game's script system.
You can now generate NewProxy using . You need to configure option Clipboard syntax to Lua. You can click on the "copy" button of a function, pick Copy NewProxy and it will copy the code in your clipboard. It only works for classes with their names ending with Listener.
Linux (Proton)
Using Cyber Engine Tweaks on Linux
For a step-by-step guide on installing the basic dependencies to make Cyberpunk run under Linux, see .
This is a basic guide to using the mod within Proton (aka Linux).
Please make sure your game works in proton first, before installing this mod.
Observing weapon hits
Example code for observing a weapon hit
Summary
Created: Oct 08 2025 by
Last documented update: Oct 08 2025 by
This page shows a code sample for reacting to hits on NPCs.
-- don't overwrite it if it's already defined in the global scope. Or do, up to you.
Cron = Cron or require('External/Cron.lua')
local callback = function()
-- do a little dance, make a little love
end
Cron.Every(0.1, callback)
Cron.Every(0.1, function()
-- do a little dance, make a little love
end)
local callback = function(timer)
timer.tick = timer.tick +1
-- do a little dance, make a little love
end
Cron.Every(0.1, { tick = 1 }, callback)
local callback = function() --[[ do a little dance, make a little love ]] end
Cron.After(0.2, callback)
local callback = function(timer)
timer.tick = timer.tick +1
spdlog.info("Timer is running: " .. tostring(timer.tick))
-- do a little dance, make a little love
if timer.tick > 150 then
Cron.Halt(timer)
end
end
-- define outside of function scope to re-use this in Cron.Pause example below
local timerArg = { tick = 1 }
-- start timer
Cron.Every(0.2, timerArg, callback)
-- callback and timer have been defined in the example above
-- the timer is running
Cron.Pause(timerArg)
spdlog.info("Timer is paused after " .. tostring(timerArg.tick) .. " ticks")
-- wait 20 seconds, then resume our function
Cron.After(20, function () Cron.Resume(timerArg) end)
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 <cet_path>/mods/ folder to get started, e.g. my_mod (snake case recommended)
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.
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.
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
This page is still heavily WIP! Perhaps you'd like to work on it?
Helpers
Helpers make it easy, some listed below
Game
Where can we use it, difference to redscript thing
GetPlayer
What is it in reds, dont store it etc.
IsDefined
Description
From/ToVariant
Classes
TODO: What names to use
Creating Instances
.new, as constructor
Member Functions
These functions are called on Handles. You do not call them on a class, but rather on an instance of a class (not NPCPuppet:isTargetingPlayer(), but npcHandle:isTargetingPlayer())
Static Functions
They do not need a handle and are all located in a class, e.g. the Game object:
Enums
How to use, nativeDB link, enumInt
CName
Function to add CNames, string to cname
Observe and Override
Note on how powerful it is etc, link to seperate doc (Observe, Override)
Blackboard System
Blackboard is a kind of shared data storage and a framework to access/notify/listen to the data in the storage. Similar to a real blackboard, game objects put their data on the board that then other objects can observe, react to or update the data. E.g. various game state values.
Handle functions
They require a handle (more on that later). Assuming you have a player handle:
Handles
Handles are a way to pass an object to the function. For example IsNaked makes no sense without telling the engine for which object we want to know this information.
Singleton
These handles are static, there is only one in the game, for example the gameTimeSystem is a singleton so there is no need to tell the script engine which one you want. That being said you need a singleton handle so it knows you want to call a function on that system.
Sample:
Regular handles
These handles are not unique, for example, the game contains multiple NPCs so there are as many handles as NPCs. Currently as far as I know we can only get the handle of the player by calling the global function Game.GetPlayer().
Sample:
Helpers
If you need to dump the content of a type, you can use the Dump function like the following:
You can also call DumpType for a static type you want to know about but don't have an instance of:
You can register an Input and make it behave like a Hotkey. This method is more reactive as it triggers on key press, when a Hotkey is triggered on release.
Usage Note
It is important to check the keypress argument inside the callback. Otherwise the code will be executed twice:
One time when the key is pressed
A second time when released
Usage Example
Activate slow motion effect as long as the input key is pressed:
Advanced Example
Continuously give money as long as the input key is pressed:
This example use the onUpdate event, which is triggered continuously. Make sure to check the documentation before any modification.
To transform a TweakDBID into a gameItemID, call ItemId.FromTDBID(tbdID)
DebugStats
Print info about the TweakDB. Displays the number of flats, records, and queries, the size in bytes of flatDataBuffer, and the number of created records.
Definition
Usage example
GameItemIdTo get a TweakDBId's human-readable record name rather than its hash, use id.value!
GetRecord
Get a TweakDB record by name or ID.
Definitions
Usage example
GetRecords
Get a table of all TweakDB records under a given type.
Definition
Usage example
Query
Get a TweakDB query by name or ID. Returns a table of TweakDBIDs.
Definitions
Usage example
GetFlat
Get a TweakDB flat by name or ID.
Definitions
Usage example
SetFlat
Set a TweakDB flat by name or ID and update it. Returns whether the flat was successfully set.
Definitions
Usage example
SetFlatNoUpdate
Set a TweakDB flat by name or ID without updating it. Returns whether the flat was successfully set.
Definitions
Usage example
Update
Update (flush data of) a TweakDB record by name, ID, or handle. Returns whether the update was successful.
Definitions
Usage example
CreateRecord
Create a new TweakDB record. Returns whether the record was created successfully.
Definitions
CloneRecord
Clone an existing record identified by clonedRecordName or clonedRecordID to a new record named recordName or with a TweakDBID of recordID. Returns whether the record was cloned successfully. If a record named recordName or with ID recordID already exists, this method will fail.
Definitions
DeleteRecord
Delete an existing TweakDB record. Returns whether the record was deleted successfully.
Definitions
Definition
CallbackName is an arbitrary name you define. A callback name can be formatted as follow On[Action] (e.g. OnDamaged or also OnPlayerDamaged).
CallbackDefinition is the signature of the script function (args) and the Lua function (callback) you want to be executed when the callback is triggered.
The list of arguments must indicate the name of the types to expect. For example with a callback function which receives a String, an Int32 and a reference to a GameObject, it should be defined like this:
In this case, you can define your function callback like this:
Find the signature of a function
The signature of the function depends on the game's script function you want to register a callback for.
You can use NativeDB to know the types of arguments to declare. By default, the syntax will be written in Redscript. You can change the option Code syntax in the settings and select Pseudocode · Legacy instead. Basically, it will show you handle:GameObject instead of ref<GameObject> (among other things).
Use a proxy
Lets create a proxy:
After creating the proxy, you can use it to pass the target and function you want to callback. Lets say a game's script is defined as:
We can call the function RegisterHit to register our callback with our proxy like this:
Note that the value, when calling listener:Function("OnHit"), is the same we declared in the proxy.
This way, you can create multiple callback in a proxy and you just need to call listener:Function with the name of the callback you want to use. For example:
Usage Examples
This example will be using Codeware and its system to listen for game events. It will listen for the event Session/Ready and print a message in CET logs.
gameTime = GetSingleton("gameTimeSystem")
-- get time
gameTime:GetGameTime()
-- set time
gameTime:SetGameTimeByHMS(12, 0, 0) -- 12h0m0s
returns
GameTime[ seconds:734466 ]
GetVersion() -> string
init.lua
version = GetVersion()
print(version)
<console>
> v1.27.1
ModArchiveExists(archiveName: string) -> bool
init.lua
print(ModArchiveExists('myModFiles.archive'))
<console>
> true
// Redscript side
public static func IsDetected_NameOfYourMod() -> Void {}
-- CET side
function IsRedscriptDetected()
return Game["IsDetected_NameOfYourMod"] ~= nil
end
// 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
-- 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
player = Game.GetPlayer()
dmp = Dump(player, false)
print(dmp)
type = DumpType("gameItemID", false)
print(type)
Game.PrintHealth()
-- or
Game.AddToInventory("Items.money", 500)
player = Game.GetPlayer()
if player:IsNaked() then
player:OnDied() -- kill the player if it's naked
end
player = Game.GetPlayer()
ts = Game.GetTransactionSystem()
tid = TweakDBID.new("Items.money")
itemid = ItemID.new(tid)
result = ts:GiveItem(player, itemid, 100000)
if result then
print("We added " .. tostring(itemid) .. " to the inventory!")
else
print("Failed to add " .. tostring(itemid))
end
registerInput(slug, label, callback)
--
-- registerInput()
--
-- @param string slug The internal slug (must be unique in your mod scope)
-- @param string label The label displayed in CET Bindings
-- @param function callback The callback function
--
registerInput('slug', 'label', function(keypress)
if keypress then
-- key is pressed
else
-- key is released
end
end)
registerInput('slug', 'label', function(keypress)
-- bail early on key release
if not keypress then
return
end
-- key is pressed
end)
registerInput('slug', 'label', function(keypress)
-- this will be called 2 times!
end)
init.lua
-- register input
registerInput('slow_motion', 'Slow Motion', function(keypress)
-- get time system
local timeSystem = Game.GetTimeSystem()
-- bail early if time system doesn't exists
if not timeSystem then
return
end
-- key is pressed
if keypress then
timeSystem:SetTimeDilation('MySlowMo', 0.3)
-- key is released
else
timeSystem:UnsetTimeDilation('MySlowMo')
end
end)
init.lua
-- set initial switch state
keep_giving = false
-- register input
registerInput('give_continuous_money', 'Give Continuous Money', function(keypress)
-- input pressed
if keypress then
keep_giving = true -- switch on
-- input released
else
keep_giving = false -- switch off
end
end)
-- onUpdate
-- this event is triggered continuously
registerForEvent('onUpdate', function()
-- check switch state
if keep_giving then
Game.AddToInventory('Items.money', 20)
end
end)
local mod = {
listener = nil
}
-- Define our function to callback
function OnReady(event)
local isMenu = event:IsPreGame()
print("Event \"Session/Ready\" triggered!")
if isMenu then
print("Player is in the pre-game menu")
else
print("Player is in the game")
end
end
registerForEvent('onInit', function()
-- Create our proxy
mod.listener = NewProxy({
OnSessionReady = {
-- Type is defined in the wiki of Codeware
args = {"handle:GameSessionEvent"},
callback = function(event) OnReady(event) end
}
})
-- Register our callback to listen for event "Session/Ready".
local callbackSystem = Game.GetCallbackSystem()
local target = mod.listener:Target()
local fn = mod.listener:Function("OnSessionReady")
callbackSystem:RegisterCallback("Session/Ready", target, fn)
end)
registerForEvent('onShutdown', function()
-- Unregister our callback before our mod is "removed".
local target = mod.listener:Target()
local fn = mod.listener:Function("OnSessionReady")
callbackSystem:UnregisterCallback("Session/Ready", target, fn)
end)
Only supports Japanese display
Korean
For Korean
Thai
For Thai
Vietnamese
For Vietnamese
Cyrillic
Supports languages that use Cyrillic scripts (e.g. Russian, Bulgarian..)
ChineseFull
Supports traditional Chinese, simplified Chinese, and Japanese display
While this isn't a required step, it's useful for performance.
Right click the game in Steam and select 'Properties'. Go to the 'Compatibility' tab and tick 'Force the use of a specific Steam Play compatibility tool'.
In the dropdown, select 'Proton Experimental'.
Setting up the mod with ProtonTricks
Please note - this method requires the use of Steam. For other options, see below.
First, follow the steps to install the mod. These are in the wiki.
Run protontricks 1091500 --gui, you may get an error saying "You are using a 64 bit WINEPREFIX", you can ignore this. Press 'Ok' when this error appears.
Choose the option 'Select the default wineprefix', then 'Run winecfg'. In the window that opens, select the 'Libraries' tab. In the dropdown on 'New override for library', select version. Click Add, then Apply and Ok.
You can now exit out of Protontricks and start your game. Check to see if the log exists after you run the game. If it's there, you've successfully installed the mod.
If you have issues with the mod still not working or the game just crashing, you can try this: re-open Protontricks like you did before, choose the option 'Select the default wineprefix', then 'Install a Windows DLL or component'. Tick vcrun2022 and press Ok. If a window pops up, then go through the steps to install that runtime (just click next really), otherwise just wait until the Protontricks screen comes back. Now exit out of Protontricks and try launching the game. DON'T do this without first checking if the mod works without this step, since installing vcrun2022 has been observed breaking game installs before, preventing the game from ever launching again and requiring a re-install.
NOTES: You will also need to install d3dcompiler_47 with winetricks to get it to work now, contribution on how to do this would be much appreciated!
If vcrun2019 breaks your install, it's been reported it can be fixed without reinstalling by deleting the contents of/steamapps/compatdata/1091500.
Setting up the mod with proton as non-Steam Game
Please note, this method still requires the use of Steam. You must install Cyberpunk 2077 and then add it to your Steam library by following the official instructions.
Search for the game APPID with: $ protontricks -s name_of_the_game_on_your_steam_lib
like:
$ protontricks -s Cyberpunk 2077
copy the APPID from the terminal then run:
$ protontricks "APPID" --gui
From now on, you can follow the Setting up the mod with ProtonTricks instructions.
Setting up the mod without Steam by using Winetricks
For users running on the GOG version of the game, via launcher like Lutris, Minigalaxy or GameHub, those running from the direct GOG Galaxy Windows application through Wine, or those directly using the Game libraries, Protontricks won´t be helpful in your case, as Protontricks will notice that you don´t have the game on Steam.
Instead, use Winetricks in which Protontricks is derivated from. Please note that you may need to install Winetricks first, either through the official website or through your distribution's app store.
Lutris users may perform the following steps to activate the mod:
Authenticate with GOG Galaxy by clicking on the small profile icon to the right of the GOG entry. You will then be presented with a list of your owned games. Select Cyberpunk and install it - this will install the base version of the game with no other options selected. You may right click on the game icon after installation and choose the option to install the Phantom Liberty DLC if desired. Once installation is complete, select Cyberpunk 2077 and click on the Winetricks 'wine flute' icon along the bottom of the Lutris window. In the expanded menu, select 'Winetricks'.
Choose the option 'Select the default wineprefix', then 'Run winecfg'. In the window that opens, select the 'Libraries' tab. In the dropdown on 'New override for library', select version. Click Add, then Apply and Ok.
Alternatively, you may run Winetricks in itself if you use your default prefix, or from your custom prefix via: WINEPREFIX=<Location of your WinePrefix directory> winetricks --gui via the terminal.
From now on, you can follow the Setting up the mod with ProtonTricks instructions. If you want to verify in Winetricks has correctly taken in account your custom Wine directory, click on Browse files to see if it brings you to the designated folder.
local function IsCritical(evt)
return evt.attackData:HasFlag(hitFlag.CriticalHit)
end
Good Practices
Codes good practices, pitfalls and tips
LUA
Gain performance: Early Return
You're probably used to coding like this:
In LUA, you can skim a few processing cycles by using the early return style:
You can gain a significant amount of performance this way, especially when doing this in a loop.
Fixing/preventing nil access
LUA throws an exception if it encounters nil in unexpected places. The corresponding error will look like this:
Open the corresponding file, find the correct line, and check what is being accessed there. It will look like variable.property, or perhaps something will be concatenated to a string ("something something text" .. variable).
You can assign a default value to the property in question:
While that won't solve any other problems, it will at least make the error go away.
Switch in LUA: Lookup Tables
Who doesn't know the problem? You want to know if your string is A, B, or C, but not D — and LUA doesn't have a switch statement.
Fortunately, there is a built-in and performant way to
Performance killers: strings
String concatenation and comparison can be the difference between a brief stutter and a complete freeze or even crash to desktop. This is not a joke — see for more detail.
Comparing/Searching
Lua internalizes strings. That means these two strings will share a single representation in memory:
The comparison between those two strings will be almost-instant.
This becomes a problem when comparing strings in a loop (see ):
Every single pass of the loop will create a memory representation of "This is the same object!" and then discard it again.
Takeaway:
If at all possible, define things outside the scope of loops!
Finding in strings
Lua's regex implementation is very limited. There is a limitation for pipes. For example, the following example will actually iterate twice after creating internal string representations:
It is faster to just do this:
On top of that, string.match will return the entire string if no match is found:
The alternative:
Takeaway:
Avoid regex
Concatenation
For a performance analysis of different kinds of string concatenation, check .
Scopes
Don't do this (30% less performant):
Do this instead:
Useful commands
A collection of commonly requested commands. How do I...
First Launch
After installing CET, you can open the console overlay with the corresponding key.
If you have any problems getting to this stage, please check the page.
The commands are case-sensitive!
Many console commands have changed with 2.0. If something you try doesn't work, check the most up-to-date list under .
Open the Console tab to run Lua scripts or engine functions. To find out what you can do here, keep reading.
Spreadsheets
To find all the codes you can enter, check
(source: #cet-support on )
For the most common commands, see below.
If you want to find a specific item, look for how to find the hash code for the .
Items
Use Game.AddToInventory
Frequently Required Items
Ammunition
Crafting Components
Quickhacks
Level
Use Game.SetLevel
Attributes
Formerly Game.SetAttribute
Perk and Skill Points
Formerly Game.GiveDevPoints
Vehicles
All vehicle commands are documented on the VehicleSystem page linked below.
Teleportation
Get your coordinates
You can print V's current coordinates to the CET console with the following command:
Go somewhere else
You will need to know the coordinates of where you want to go in the game world, some popular . Replace X, Y, and Z with your coordinates. Coordinates can also be found in the nodeData of .streamingsector files.
Facts
At this time there is no way of triggering or "fixing" stuck quests with the console.
Spoilers!
Secret Ending
For a more cohesive list of quest facts, check the .
UI Examples
This page contains examples for creating UI for your mod using the built-in ImGui library.
Everything you need to know about Dear ImGui can be found here and here.
You can also take a look at FellowImGui. It is a free online tool to create ImGui layouts with an easy to use interface. It also generates Lua code for you. Feel free to come on this Discord channel if you have issues or feedback to share.
Any ImGui code needs to be run from inside the callback.
Basic Window
Modal/Popup Window
Combo Box with Selectables
Checkbox
Button
Tooltip
Default tooltip on a button.
To customize the tooltip window use BeginTooltip and EndTooltip.
Multi-column layout
Creating a multi-column layout is a pain in the ass, but you can go about it like this:
You can probably use dynamic dimensions somehow. If you find out, please update this guide.
Cyber Engine Tweaks allow mods to register hotkeys that can be assigned by the player in the , and execute custom code once pressed. There are two kinds of hotkeys:
---@param request PerformFastTravelRequest
Observe("FastTravelSystem", "OnPerformFastTravelRequest", function(request)
-- Now request object has type and suitable for code completion
end)
---@type ScriptedPuppet
local puppet
local adjustRequest = AdjustTransformWithDurations.new();
-- Setting any duration to 0 or lower means "do not change"
-- Slide = change player position
-- Rotation = change player rotation / trajectory / viewing angles
adjustRequest:SetSlideDuration(-1.0); -- Disabling position adjustion
adjustRequest:SetRotationDuration(1); -- Rotation show be smooth and should happen in 1 second (presumably, second!)
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources
adjustRequest:SetRotation(ToEulerAngles {0, 0, 0}:ToQuat()); -- Setting target player's rotation
stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);
local adjustRequest = AdjustTransformWithDurations.new();
adjustRequest:SetSlideDuration(-1.0); -- Disabling position adjustion
adjustRequest:SetRotationDuration(1.0); -- Rotation show be smooth and should happen in ~1 second (presumably, seconds!)
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources
-- In this case aimAt is a GameObject
adjustRequest:SetTarget(aimAt); -- Setting target player's rotation
stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);
local adjustRequest = AdjustTransformWithDurations.new();
adjustRequest:SetSlideDuration(1.0); -- Setting duration of position change.
adjustRequest:SetRotationDuration(-1.0); -- Disabling rotation adjustion
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources
-- Getting player's position
local playerPosition = Game.GetPlayer():GetWorldPosition();
-- Adding 10 on the vertical axis
playerPosition.z = playerPosition.z + 10;
adjustRequest:SetPosition(playerPosition);
stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);
init.lua
local function OnWeaponHit(this, evt) -- https://nativedb.red4ext.com/gameHitEvent
-- check that the player was the one who hit this npc
-- https://nativedb.red4ext.com/AttackData
if not IsDefined(evt.attackData.instigator) or not evt.attackData.instigator:IsPlayer() then return end
local record = evt.attackData.weapon.weaponRecord -- https://nativedb.red4ext.com/gamedataWeaponItem_Record
local id = record:GetID().value -- make sure to stringify the TweakDBID so we can print and search
print("weapon id: " .. id);
if string.find(id, "Items.your_string_here") then
print("yay")
end
end
registerForEvent("onInit", function()
ObserveAfter('NPCPuppet', 'OnHit', OnWeaponHit)
end)
local function IsKill(evt)
return evt.attackData:HasFlag(hitFlag.Kill)
end
local function myMethod()
if condition then
-- do a little dance, make a little love…
end
end
local function myMethod()
if not condition then return end
-- do a little dance, make a little love…
end
attempt to access local '<variable name>' (a nil value)
stack traceback:
my_example.lua:1234 in function 'MyFunctionName
myString = <original string assignment> or ""
myNumber = <original number assignment> or 0
myEverythingElse = <original object assignment> or {}
local string1 = "This is the same object!"
local string2 = "This is the same object!"
for (_, mystring) in ipairs(mytable) do
if mystring == "This is the same object!" then
-- do something
end
end
local myCompareString = "This is the same object!"
for (_, mystring) in ipairs(mytable) do
if mystring == myCompareString then
-- do something
end
end
if string.find("catastrophe", "dog|cat") then
-- do something
end
if string.find("catastrophe", "dog") or string.find("catastrophe", "cat") then
-- do something
end
local match = string.match("catastrophe", "dog")
if match ~= "catastrophe" then
-- do something
end
if string.find("catastrophe", "dog")
-- do something
end
function foo(x)
for i = 1, 1000000 do
x = x + math.sin(i)
end
return x
end
local sin = math.sin
function foo(x)
for i = 1, 1000000 do
x = x + sin(i)
end
return x
end
ImGui.SetNextWindowPos(100, 500, ImGuiCond.FirstUseEver) -- set window position x, y
ImGui.SetNextWindowSize(300, 600, ImGuiCond.Appearing) -- set window size w, h
if ImGui.Begin("Unique Window Name") then
ImGui.Text("Hello World")
-- more window contents here
end
ImGui.End()
if ImGui.Button("Pop Button", 120, 0) then
ImGui.OpenPopup("Delete?")
end
if ImGui.BeginPopupModal("Delete?", true, ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text("This is a popup")
if ImGui.Button("Close") then ImGui.CloseCurrentPopup() end
ImGui.EndPopup()
end
local DropdownOptions = {"1", "2", "3", "4", "5"}
local DropdownSelected = "1"
if ImGui.BeginCombo("##My Combo Box", DropdownSelected) then -- Remove the ## if you'd like for the title to display above combo box
for _, option in ipairs(DropdownOptions) do
if ImGui.Selectable(option, (option == DropdownSelected)) then
DropdownSelected = option
ImGui.SetItemDefaultFocus()
end
end
ImGui.EndCombo()
end
if ImGui.Button("Click Me!", 100, 20) then -- Label, width, height - Use -1 as width for button to span available horizontal space
-- do stuff here when button is clicked
end
local pressed
registerForEvent("onUpdate", function()
if pressed then
print("You pressed me!")
end
end)
registerForEvent("onDraw", function()
pressed = ImGui.Button("Click me I'm a Sexy Button", 250, 25)
end)
local pressed = ImGui.Button("button text")
if ImGui.IsItemHovered() then
ImGui.SetTooltip("tooltip text")
else
ImGui.SetTooltip(nil)
end
local pressed = ImGui.Button("button text")
if ImGui.IsItemHovered() then
ImGui.BeginTooltip()
ImGui.PushTextWrapPos(50)
ImGui.TextWrapped("tooltip text")
ImGui.EndTooltip()
else
ImGui.SetTooltip(nil)
end
ImGui.BeginChild("Column 1", 300, 400) -- this will not display a label
ImGui.Text('Column 1')
ImGui.EndChild()
ImGui.BeginChild("Column 2", 300, 400) -- this will not display a label
ImGui.Text('Column 2')
ImGui.EndChild()
Hotkeys and Inputs, while having similar functionalities, are displayed in two separated groups.
General Notes
Hotkeys are not triggered while the player stay pressed on a game's keybind.
For example, if the player move forward with "W" and press a Hotkey at the same time, it won't be triggered.
For this reason, it is recommended to use Inputs instead, as they are always triggered.
Remember to register Hotkeys/Inputs at root level, outside of any event.
Hotkeys & Inputs are displayed in the CET Bindings screen sorted in the order they were registered in the code. If you want to sort hotkeys by label in ascending order for example, you'll have to change the registration code order accordingly.
Hotkeys & Inputs can be triggered by the user from anywhere, at anytime, as soon as CET loaded your mod (even earlier than onInit event).
Which means the user might press your hotkey in the Main Game Menu or in Settings Menu. You have to keep that in mind when working with hotkeys, and make sure your script is executed where it is supposed to.
Hotkeys & Inputs are triggered on top of the game's keybinds. Which means it's possible that player set a hotkey on "R".
In-game, when the player use "R" to trigger your script, it will also trigger the game's Reload function.
Prints one or more objects to the CET Console and CET Console Logs file. Multiple objects will be printed separated by a space.
Definition
Usage example
spdlog
Write a string in the file, eg, <cet_path>/mods/my_mod/my_mod.log.
There are several spdlog methods, all are identical and have the same output:
spdlog.debug()
spdlog.trace()
spdlog.info()
Definition
Usage example
Usage tips
It is recommended to use spdlog.info(tostring(my_var)) to make sure the variable is compatible, as boolean, interger and other types will throw an error.
Dump()
Returns a JSON-ish string with details about the members of obj:
Type name
Instance functions
Static functions
The listed functions include their signatures.
If detailed is true, function descriptions will include the function's full name hash, short name, and short name hash.
obj must be an instance of a wrapped game type, such as PlayerPuppet which is returned by Game.GetPlayer(). will dump the names of all such types.
Definition
Usage example
GameDump()
Returns the game's internal debug string for the given object. This string displays the object's properties and their values.
Beware that this string probably won't have any line breaks, so it's more advisable to open <cet_path
Definition
Usage example
DumpType()
Like , but takes a type name rather than an object instance. Use to get a list of all types.
Definition
Usage example
DumpAllTypeNames()
Dump all type names to <cet_path>/cyber_engine_tweaks.log and prints to the the number of types dumped.
Definition
Usage example
Debug
A debug helper class
Summary
This page contains the source code for the debug helper class, along with examples on how to use it.
If you just want to log something, check Logs & Debug.
What does this class do?
Prints one or multiple objects into
Prints one or multiple objects into file
Pretty-print table (with indent)
Source code
Definitions
Prints to , similar to function.
Write in file. eg, <cet_path>/mods/my_mod/my_mod.log. Similar to .
Usage example
Clothing Recipes
This is a preliminary list of item hashes for clothes recipes, provided by Bettik#0331. I have preserved it here so the data doesn't get lost until we can find a proper home for it.
debug = {
-- log
log = function(...)
spdlog.info(debug.parse(...))
end,
-- print
print = function(...)
print(debug.parse(...))
end,
-- parse arguments
parse = function(...)
local args = {}
for _, v in pairs{debug.null(...)} do
table.insert(args, debug.parseDeep(v))
end
local output = ""
for i, value in pairs(args) do
output = output .. tostring(value)
if i ~= #args then
output = output .. " "
end
end
return output
end,
-- parse deep table
parseDeep = function(t, max, depth)
-- convert nil to 'nil'
t = debug.null(t)
if type(t) ~= 'table' then
if type(t) == 'userdata' then
t = debug.parseUserData(t)
end
return t
end
max = max or 63
depth = depth or 4
local dumpStr = '{\n'
local indent = string.rep(' ', depth)
for k, v in pairs(t) do
-- vars
local ktype = type(k)
local vtype = type(v)
local vstr = ''
-- key
local kstr = ''
if ktype == 'string' then
kstr = string.format('[%q] = ', k)
end
-- string
if vtype == 'string' then
vstr = string.format('%q', v)
-- table
elseif vtype == 'table' then
if depth < max then
vstr = debug.parseDeep(v, max, depth + 4)
end
-- userdata
elseif vtype == 'userdata' then
vstr = debug.parseUserData(v)
-- thread (do nothing)
elseif vtype == 'thread' then
-- else
else
vstr = tostring(v)
end
-- format dump
if vstr ~= '' then
dumpStr = string.format('%s%s%s%s,\n', dumpStr, indent, kstr, vstr)
end
end
-- unindent
local unIndent = indent:sub(1, -5)
-- return
return string.format('%s%s}', dumpStr, unIndent)
end,
-- parse userdata
parseUserData = function(t)
local tstr = tostring(t)
if tstr:find('^ToCName{') then
tstr = NameToString(t)
elseif tstr:find('^userdata:') or tstr:find('^sol%.') then
local gdump = false
local ddump = false
pcall(function() gdump = GameDump(t) end)
pcall(function() ddump = Dump(t, true) end)
if gdump then
tstr = GameDump(t)
elseif ddump then
tstr = ddump
end
end
return tstr
end,
-- convert nil into 'nil'
null = function(...)
local t, n = {...}, select('#', ...)
for k = 1, n do
local v = t[k]
if v == debug.null then t[k] = 'nil'
elseif v == nil then t[k] = debug.null
end
end
return (table.unpack or unpack)(t, 1, n)
end,
}
debug.print(obj: object [, obj2, ...]) -> nil
debug.log(obj: object [, obj2, ...]) -> nil
init.lua
local myTable = {
var = true,
enabled = false,
subTable = {
player = Game.GetPlayer(),
stats = Game.GetStatsSystem()
}
}
debug.log('myTable:', myTable)
Observers are builtin CET functions that allow developers to detect when a function/method is executed by the game. They must be registered inside the onInit event, in the init.lua file.
ObserveBefore() which is triggered right at the moment the function/method is called
ObserveAfter() which is triggered once the game finished to execute the function/method
The provided callback is always filled as follow:
The first argument is the current object that execute the function/method. This argument is not present when function/method is static.
Others arguments passed to the targeted function/method, if any.
You can now generate Observable and ObservableAfter using . You need to configure option Clipboard syntax to Lua. You can click on the "copy" button of a function, pick Copy Observable or Copy ObservableAfter and it will copy the code in your clipboard.
Definition
Observe() is an alias of ObserveBefore(). They both work the same.
If you observe a static function, you must define the field 'method' with the full name of the function. Otherwise it won't work. You can find the full name using . See for an example.
Representation
Here is a visual representation showing where observers are executed in the game's script:
In this representation, the observer callback would be filled with the following arguments:
The self parameter can be renamed at your convenience:
_
In the code above, the observer listens to AimingStateEvents:OnEnter(), which is triggered everytime the player enters in ADS state.
Additionally, the OnEnter() method is responsible to apply different effects, like the camera zoom, the initial stamina drain etc... Following this logic, this means:
Using ObserveBefore() allows to hook in before these effects are applied
Using ObserveAfter() guarantees the method finished to apply all the effects
Usage Examples
Give money each time the player crouches:
Give money as long as the player is crouched:
Observe event send to an (click on function's name in NativeDB to copy the full name in your clipboard):
Advanced Example
Give money when the player is crouched and in ADS:
Override
It is generally advisable to useObserve whenever possible, and only use Override when absolutely necessary
Override is a built-in CET function allowing developers to rewrite a game's class method. It must be registered using the Override() function inside the onInit event, in the init.lua file.
The provided callback is always filled as follows:
The first argument is the current object that execute the method. This argument is not present when function/method is static.
Others arguments passed to the targeted method, if any.
The last argument is the original callable method.
You can now generate Override using . You need to configure option Clipboard syntax to Lua. You can click on the "copy" button of a function, pick Copy Override and it will copy the code in your clipboard.
Definition
If you override a static function, you must define the field 'method' with the full name of the function. Otherwise it won't work. You can find the full name using . See a similar example with .
Representation
Considering the following class and method:
When applying Override(), the callback would be filled with the following arguments:
The self and wrappedMethod parameters can be renamed at your convenience:
_
Using Wrapped Method
The last argument of the Override() function, wrappedMethod, contains the original method as a callable function. We can use it to execute the original code and/or retrieve its result (if it returns something).
It is highly recommended to know the overriden method return statement to avoid breaking the script, and use wrappedMethod accordingly.
Method -> Void
Any method declared void doesn't return a value. Overriding it follow the same logic:
Method -> Bool / Int / Float etc...
The same logic is applied to methods with a specific return statement. Overriding it must return a compatible type:
It is not required to execute the original code using wrappedMethod. This can be omitted, but it exposes the script to malfunctions if not handled properly.
Usage Example
Do not allow the player to crouch:
Advanced Example
Do not allow the player to crouch if in ADS:
Files
File Exists
Definition
Upgrade Guide
General Instructions
Key notes on upgrading existing mod for the CET 1.14+:
Don't pass excessive params to game functions. If the max number of params is 3, then passing 4 params will result in an error.
Update Observe() / Override() handlers so they accept self as the first param. Previously, some observers lacked the self param:
If your mod stores player reference then unset it when game session ends.
An unreleased reference can lead to bugs such as disappearing footsteps.
Accessing Game.GetPlayer() in onUpdate will not cause the issue.
This can be achieved using next snippet or with GameSession / GameUI libs:
Use corresponding getters for game systems instead of GetSingleton(). For example, Game.GetTeleportationFacility() instead of GetSingleton('gameTeleportationFacility').
New Script API
New scripting capabilities were introduced in CET 1.14 to make it more convenient and simple:
All game classes are directly accessible by name. For example, entEntityId, PlayerPuppet.
All game enums are directly accessible by name. For example, gamedataStatType.BaseDamage, gameGameVersion.Current.
Classes can also be accessed by their aliases from redscript. For example, WeaponObject instead of gameweaponObject.
Classes have the conventional .new() constructor. For example, MappinData.new().
A constructor can take an array of properties to create and initialize an object in a single statement. For example, EntityID.new({ hash = 12345 }).
Static methods are accessible from classes using the dot. For example, ScriptedPuppet.IsDefeated(npc).
A static method can be called from an instance if the first parameter is of the same type. For example, vec4:Length() instead of Vector4.Length(vec4).
The overloaded function is resolved based on passed parameters when called by its short name. For example, StatusEffectHelper.HasStatusEffect(target, gamedataStatusEffectType.Overheat).
Partial Variant type support. ToVariant() and FromVariant() are only applicable to classes.
Backward Compatibility
All new scripting features are optional. You're not required to rewrite an existing mod using these features.
Redscript Similarity
The new API allows code that is also valid redscript or very close to its redscript counterpart. Thus, it simplifies the research and the transition to / from the redscript.
For example, this line looks exactly the same in Lua and in the redscript:
Examples
Constructing objects
Old API:
New API:
Constructor with initialization
Old API:
New API:
Scripted static call
Old API:
New API:
Shorthand static call
Old API:
New API:
Working with enums
Old API:
New API:
Variants
Observe(className, method, callback) -- alias of ObserveBefore()
ObserveBefore(className, method, callback)
ObserveAfter(className, method, callback)
--
-- ObserveBefore()
--
-- @param string className The parent class name
-- @param string method The method name to target
-- @param function callback The callback function
--
ObserveBefore('className', 'method', function(self [, arg1, arg2, ...])
-- method() has just been called
end)
--
-- ObserveAfter()
--
-- @param string className The parent class name
-- @param string method The method name to target
-- @param function callback The callback function
--
ObserveAfter('className', 'method', function(self [, arg1, arg2, ...])
-- method() has been called and fully executed
end)
public class AimingStateEvents extends UpperBodyEventsTransition {
protected func OnEnter(stateContext: ref<StateContext>, scriptInterface: ref<StateGameScriptInterface>) -> Void {
// ObserveBefore('AimingStateEvents', 'OnEnter')
let aimingCost: Float;
let focusEventUI: ref<FocusPerkTriggerd>;
let timeDilationFocusedPerk: Float;
let weaponType: gamedataItemType;
let player: ref<PlayerPuppet> = scriptInterface.executionOwner as PlayerPuppet;
// ...
// ObserveAfter('AimingStateEvents', 'OnEnter')
}
}
Observe('AimingStateEvents', 'OnEnter', function(self, stateContext, scriptInterface)
-- self the 'AimingStateEvents' class
-- stateContext the original method argument
-- scriptInterface the original method argument
end)
-- onInit
registerForEvent('onInit', function()
-- observe crouch OnUpdate state
-- this is triggered continuously, as long as the player is crouched
Observe('CrouchEvents', 'OnUpdate', function(self, timeDelta, stateContext, scriptInterface)
Game.AddToInventory('Items.money', 20)
end)
end)
-- init.lua
-- onInit
registerForEvent('onInit', function()
-- NativeDB will copy 'entAnimationControllerComponent::PushEvent;GameObjectCName'
-- We can ignore the left part to only keep:
Observe('AnimationControllerComponent', 'PushEvent;GameObjectCName', function(gameObject, eventName)
print('GameObject:', gameObject:GetClassName())
print('Event:', eventName)
end)
end)
init.lua
-- set initial vars
isADS = false
isCrouch = false
-- decide to give money
-- this function can be defined outside of onInit
-- as it is only called within observers
shouldGiveMoney = function()
-- is in ADS and is crouched
if isADS and isCrouch then
Game.AddToInventory('Items.money', 1000)
end
end
-- onInit
registerForEvent('onInit', function()
-- observe ADS OnEnter state
Observe('AimingStateEvents', 'OnEnter', function(self, stateContext, scriptInterface)
isADS = true
shouldGiveMoney()
end)
-- observe ADS OnExit state
Observe('AimingStateEvents', 'OnExit', function(self, stateContext, scriptInterface)
isADS = false -- reset condition
end)
-- observe Crouch OnEnter state
Observe('CrouchEvents', 'OnEnter', function(self, stateContext, scriptInterface)
isCrouch = true
shouldGiveMoney()
end)
-- observe Crouch OnExit state
Observe('CrouchEvents', 'OnExit', function(self, stateContext, scriptInterface)
isCrouch = false -- reset condition
end)
end)
Override(className, method, callback)
--
-- Override()
--
-- @param string className The parent class name
-- @param string method The method name to target
-- @param function callback The callback function
--
Override('className', 'method', function(self [, arg1, arg2, ...], wrappedMethod)
-- rewrite method()
end)
public class AimingStateEvents extends UpperBodyEventsTransition {
protected func OnEnter(stateContext: ref<StateContext>, scriptInterface: ref<StateGameScriptInterface>) -> Void {
let aimingCost: Float;
let focusEventUI: ref<FocusPerkTriggerd>;
let timeDilationFocusedPerk: Float;
let weaponType: gamedataItemType;
let player: ref<PlayerPuppet> = scriptInterface.executionOwner as PlayerPuppet;
// ...
}
}
Override('AimingStateEvents', 'OnEnter', function(self, stateContext, scriptInterface, wrappedMethod)
-- self the 'AimingStateEvents' object
-- stateContext the original method first argument
-- scriptInterface the original method second argument
-- wrappedMethod the original 'OnEnter' callable method
end)
public class CrouchDecisions extends LocomotionGroundDecisions {
public func OnStatusEffectApplied(statusEffect: wref<StatusEffect_Record>) -> Void {
// ...
}
}
Override('CrouchDecisions', 'OnStatusEffectApplied', function(self, statusEffect, wrappedMethod)
-- execute original code
wrappedMethod(statusEffect)
-- do something
end)
public class CrouchDecisions extends LocomotionGroundDecisions {
protected cb func OnControllingDeviceChange(value: Bool) -> Bool {
// ...
}
}
Override('CrouchDecisions', 'OnControllingDeviceChange', function(self, value, wrappedMethod)
-- execute & retrieve original code
local result = wrappedMethod(value)
-- check our condition
if condition then
return result -- return original code
else
return false -- return false
end
end)
function getFilesRecursive(path, maxDepth, depth, storage)
-- vars
path = path or '.'
maxDepth = maxDepth or -1
depth = depth or 0
storage = storage or {}
-- validate maxDepth
if maxDepth ~= -1 and depth > maxDepth then
return storage
end
-- sanitize path leading "."
if not string.find(path, '^%.') then
path = '.' .. path
end
-- sanitize path leading double "//"
if string.find(path, '^%.//') then
path = string.gsub(path, '^%.//', './')
end
-- get dir/files
local files = dir(path)
-- validate files
if not files or (type(files) == 'table' and #files == 0) then
return storage
end
-- loop files
for _, file in ipairs(files) do
-- directory
if file.type == 'directory' then
getFilesRecursive(path .. '/' .. file.name, maxDepth, depth + 1, storage)
-- lua file
elseif string.find(file.name, '%.lua$') then
table.insert(storage, path .. '/' .. file.name)
end
end
return storage
end
function getFoldersRecursive(path, maxDepth, depth, storage)
-- vars
path = path or '.'
maxDepth = maxDepth or -1
depth = depth or 0
storage = storage or {}
-- validate maxDepth
if maxDepth ~= -1 and depth > maxDepth then
return storage
end
-- sanitize path leading "."
if not string.find(path, '^%.') then
path = '.' .. path
end
-- sanitize path leading double "//"
if string.find(path, '^%.//') then
path = string.gsub(path, '^%.//', './')
end
-- get dir/files
local files = dir(path)
-- validate files
if not files or (type(files) == 'table' and #files == 0) then
return storage
end
-- loop files
for _, file in ipairs(files) do
-- directory
if file.type == 'directory' then
table.insert(storage, path .. '/' .. file.name)
getFoldersRecursive(path .. '/' .. file.name, maxDepth, depth + 1, storage)
end
end
return storage
end
Observe("PlayerPuppet", "OnAction", function(self, action)
-- First param self is required now
end)
Observe("QuestTrackerGameController", "OnUninitialize", function()
if Game.GetPlayer() == nil then
Mod.Player = nil -- var containing a reference to the player
end
end)
Create a new Vector4 from a table of x, y, z, and w floats.
You may notice that functions like PlayerPuppet:GetWorldPosition will return a Vector4, even though, intuitively, 3D coordinates only include x, y, and z values. These Vector4 values are known as in graphical programming, useful in matrix transformations.
All you really need to know is that the 4th value, w, should always be 1 when you are dealing with 3D coordinates.
Create an ItemID from a table of id, rng_seed, an unknown field unknown, and an unknown field maybe_type.
Hooks
A custom hooks system for your LUA script
Do Action / Add Action
Definitions
How To Teleport
How to teleport V
When teleporting to otherwise inaccessible areas, you may not be able to exit these locations naturally. It is recommended that you log your location before teleporting so that you can teleport back after exploring said areas.
tFlat = {
get = function(obj, path, default)
-- get path array
path = tFlat.split(path)
-- vars
local length = #path
local current = obj
local key
-- loop through path
for index = 1, length, 1 do
-- current key
key = path[ index ]
-- convert key to number (sequential table)
if tonumber(key) then
key = tonumber(key)
end
-- stop searching if a child object is missing
if current[ key ] == nil then
return default
end
current = current[ key ]
end
return current
end,
has = function(obj, path)
return tFlat.get(obj, path) ~= nil
end,
set = function(obj, path, val)
-- get path array
path = tFlat.split(path)
-- vars
local length = #path
local current = obj
local key
-- loop through path
for index = 1, length, 1 do
-- current key
key = path[ index ]
-- convert key to number (sequential table)
if tonumber(key) then
key = tonumber(key)
end
-- set value on last key
if index == length then
current[ key ] = val
-- current key exists
elseif current[ key ] then
if type(current[ key ]) ~= 'table' then
current[ key ] = {}
end
current = current[ key ]
-- current key doesn't exist
else
current[ key ] = {}
current = current[ key ]
end
end
-- return
return obj
end,
insert = function(obj, path, val)
-- get target
local target = tFlat.get(obj, path)
-- check if table and sequential
if type(target) == 'table' and tFlat.isSequential(target) then
table.insert(target, val)
end
-- return
return obj
end,
delete = function(obj, path)
-- get path array
path = tFlat.split(path)
-- vars
local length = #path
local current = obj
local key
-- loop through path
for index = 1, length, 1 do
-- current key
key = path[ index ]
-- convert key to number (sequential table)
if tonumber(key) then
key = tonumber(key)
end
-- set value on last key
if index == length then
current[ key ] = nil
else
current = current[ key ] or {}
end
end
-- return
return obj
end,
split = function(s)
s = tostring(s)
local fields = {}
local pattern = string.format("([^%s]+)", '.')
string.gsub(s, pattern, function(c)
fields[ #fields + 1 ] = c
end)
return fields
end,
isSequential = function(array)
for k, _ in pairs(array) do
if type(k) ~= "number" then
return false
end
end
return true
end,
}
local this
this = {
storage = {
actions = {},
filters = {}
},
addAction = function(action, callback, priority, context)
if type(action) == 'string' and type(callback) == 'function' then
priority = tonumber(priority or 10)
this._addHook('actions', action, callback, priority, context)
end
return this
end,
doAction = function(...)
local args = { ... }
local action = table.remove(args, 1)
if type(action) == 'string' then
this._runHook('actions', action, args)
end
return this
end,
removeAction = function(action, callback)
if type(action) == 'string' then
this._removeHook('actions', action, callback)
end
return this
end,
addFilter = function(filter, callback, priority, context)
if type(filter) == 'string' and type(callback) == 'function' then
priority = tonumber(priority or 10)
this._addHook('filters', filter, callback, priority, context)
end
return this
end,
applyFilters = function(...)
local args = { ... }
local filter = table.remove(args, 1)
if type(filter) == 'string' then
return this._runHook('filters', filter, args)
end
return this
end,
removeFilter = function(filter, callback)
if type(filter) == 'string' then
this._removeHook('filters', filter, callback)
end
return this
end,
_removeHook = function(type, hook, callback, context)
if not this.storage[type][hook] then
return
end
if not callback then
this.storage[type][hook] = {}
else
local handlers = this.storage[type][hook]
--local i
if not context then
for i = #handlers, 1, -1 do
if handlers[i].callback == callback then
table.remove(handlers, i)
end
end
else
for i = #handlers, 1, -1 do
local handler = handlers[i]
if handler.callback == callback and handler.context == context then
table.remove(handlers, i)
end
end
end
end
end,
_addHook = function(type, hook, callback, priority, context)
local hookObject = {
callback = callback,
priority = priority,
context = context
}
local hooks = this.storage[type][hook]
if hooks then
table.insert(hooks, hookObject)
hooks = this._hookInsertSort(hooks)
else
hooks = { hookObject }
end
this.storage[type][hook] = hooks
end,
_hookInsertSort = function(hooks)
local tmpHook, j, prevHook
for i = 2, #hooks do
tmpHook = hooks[i]
j = i
prevHook = hooks[j - 1]
while prevHook and prevHook.priority > tmpHook.priority do
hooks[j] = hooks[j - 1]
j = j - 1
prevHook = hooks[j - 1]
end
hooks[j] = tmpHook
end
return hooks
end,
_runHook = function(type, hook, args)
local handlers = this.storage[type][hook]
if not handlers then
return type == 'filters' and args[1] or false
end
local i = 1
local len = #handlers
if type == 'filters' then
for i = 1, len do
args[1] = handlers[i].callback(unpack(args))
end
else
for i = 1, len do
handlers[i].callback(unpack(args))
end
end
return type == 'filters' and args[1] or true
end
}
-- history storage
local actionHistory = {}
addAction = function(...)
this.addAction(...)
return this
end
removeAction = function(...)
this.removeAction(...)
return this
end
doAction = function(...)
local args = {...}
local action = args[1]
actionHistory[action] = 1
this.doAction(...)
actionHistory[action] = 0
return this
end
doingAction = function(action)
return actionHistory[action] == 1
end
didAction = function(action)
return actionHistory[action] ~= nil
end
currentAction = function()
for k in pairs(actionHistory) do
if actionHistory[k] then
return k
end
end
return false
end
addFilter = function(...)
this.addFilter(...)
return this
end
removeFilter = function(...)
this.removeFilter(...)
return this
end
applyFilters = function(...)
return this.applyFilters(...)
end
This is an evolving list. Not all locations are included here.
Location
Coordinates
Akulov penthouse
-1218.135986, 1409.635010, 113.524445
Peralezes Apt
-75.815399, -113.607819, 111.161728
Gutierrez Apt
20.760391, 5.750076, 138.900955
Base Status Effects
Descriptions of effects that can be passed into certain functions such as Game.ApplyEffectOnNPC(), any function that takes effect as a parameter.
Working Effects
AndroidTurnOff
print(Game.GetPlayer():GetWorldPosition())
// example showing necessary parameters as <?>
Game.GetTeleportationFacility():Teleport(GetPlayer(), ToVector4{x=<?>, y=<?>, z=<?>, w=1}, ToEulerAngles{roll=0, pitch=0, yaw=45})
// example usage with real coords
Game.GetTeleportationFacility():Teleport(GetPlayer(), ToVector4{x=-1442.981689, y=139.817459, z=141.996506, w=1}, ToEulerAngles{roll=0, pitch=0, yaw=45})
Makes NPC T-Pose
AndroidTurnOn
Puts them in combat search state, but with a sleep status effect symbol over their head. Kinda weird
BerserkNPCBuff
Works the same for both applying to NPC & Player
Unsure which is stronger this is BeserkPlayerBuff
BerserkPlayerBuff
Works the same for both applying to NPC & Player
Unsure which is stronger this is BeserkNPCBuff
Burning
Bleeding
Blind
CPO_Shocked
CombatStim
Visual fx from healing
Cloaked
Only sound effect plays for both Player & NPC
CloakedOda
Only sound effect plays for both Player & NPC
CyberwareMalfunction
CyberwareMalfunctionLvl2
CyberwareMalfunctionLvl3
Defeat
Drugged
Freezes an NPC in place, Player gets a tiny visual effect
Drunk
Gives visual effect only to Player
Electrocuted
EMP
Encumbered
Effects NPCs weirdly, had me blow up in flames after hitting me...
ForceKill
Grappled
Briefly puts weapon away then pulls it back out. Same for both NPCs and Player.
GlowingTattoos
Invulnerable
KenjutsuBleeding
KerenzikovPlayerBuff
LocomotionMalfunctionLevel4Passive
Works similar as encumbered, but puts target in combat state
MemoryWipeLevel2
Works as expected on NPCs
Slight visual/sound fx and combat state enabled for Player
NetwatcherGeneral
Glitch/Hacked visual effect
OutOfOxygen
Removes player drowning/out of oxygen
Overload
Works as expected when applied to NPC
Visual fx for Player no damage is done
VehicleHighDamageOverTime
VehicleLowDamageOverTime
SecondaryKnockdown
Same effect as getting hit by a car but no damage
Sets NPCs into combat mode only, no actual visual knockdown occurs
SecondHeart
Visual effect and some stat boost that I couldn't figure out maybe a health boost. After that a stun effect ocurs briefly.
SetFriendly
Puts NPC into cyberpsychosis state
Visual/sound fx for Player
Stun
SystemCollapse
Instakills NPC, looks like both overload effect
Sound fx when applied to Player but no damage is done
SuicideWithWeapon
Puts Player in combat mode.
Makes NPC commit suicide
Broken or Not Understood Effects
AlcoholDebuff
BeingCarried
DismemberedArmLeft
DismemberedArmRight
DismemberedHandLeft
DismemberedHandRight
DismemberedLegLeft
DismemberedLegRight
CyberspacePresence
DefeatWithRecover
DodgeInvulnerability
ForceDive
ForceSwim
HoverJumpPlayerBuff
HumanShield
JamCommunications
Ping
PingLevel2
PingLevel3
PingLevel4
SuppressNoise
VehicleKnockdown
Untested
AntiVirusCooldown
BaseQuickHackDuration
BerserkCooldown
BikeKnockdown
BlockBodyDisposal
BlockBroken
BlockCoverVisibilityReduction
BlockGrapple
BossNoInterrupt
BossNoTakeDown
BossTakedownCooldown
BrainMeltCooldown
BreathingHeavy
BreathingLow
BreathingMedium
BreathingSick
CallInCooldown
CommsNoiseCooldown
CommsNoisePassiveEffect
ContagionCooldown
CrippledArmLeft
CrippledArmRight
CrippledHandLeft
CrippledHandRight
CrippledLegLeft
CrippledLegRight
Deaf
DistractionDuration
DodgeAirBuff
DodgeAirCooldown
DodgeBuff
DodgeCooldown
DoNotBlockShootingOnFriendlyFire
FollowerDefeated
GrenadeCooldown
InvulnerableAfterDefeated
JohnnySicknessHeavy
JohnnySicknessLow
JohnnySicknessMedium
JohnnySicknessMediumQuest
MadnessCooldown
MemoryWipeCooldown
MonowireGrapple
MuteAudioStims
NonInteractable
OverheatCooldown
OverloadCooldown
PainInhibitors
Parry
PlayerBleeding
PlayerBurning
PlayerElectrocuted
PlayerExhausted
PlayerMovementLocked
PlayerPoisoned
Poisoned
QuickHackCooldownDuration
QuickHackUploaded
RebootOpticsBossCooldown
RebootOpticsCooldown
ReduceNextHackCostBy1
ReduceUltimateHackCostBy2
RemoteBreachCooldown
SandevistanBuff
SandevistanCooldown
SandevistanPlayerBuff
StrongArmsChemicalActive
StrongArmsElecricActive
StrongArmsPhysicalActive
StrongArmsThermalActive
SuicideCooldown
SystemCollapseCooldown
TemporarilyBlockMovement
ThreeOrMoreProgramsCooldownRedPerk
ThreeOrMoreProgramsMemoryRegPerk1
ThreeOrMoreProgramsMemoryRegPerk2
Unconscious
UncontrolledMovement_Default
UncontrolledMovement_RagdollOffLedge
VehicleTrunkBodyPickup
WasQuickHacked
WaterCollision
WhistleCooldown
Wounded
Time Machine Guitar room
-1843.676392, -575.336243, 7.754036
Denny's Estate Inside
486.977325, 1291.791016, 234.458664
Hanako Estate bedroom
290.197662, 1022.468079, 229.920425
Voodoo Boys Subway
-1662.758545, -1867.002563, 54.982040
Slayton Apt
-1450.692139, -1038.510742, 77.555298
NCPD Conference room
-1761.547729, -1010.821655, 94.300003
JigJig St. hotel room
-664.977112, 847.753113, 28.499626
Dark Matter hotel room
-372.268982, 271.240143, 215.515579
Megatower H8 penthouse
-701.484680, 849.270264, 322.252228
Mr. Hands (Heavy Hearts)
-1577.5237, -2336.9883, 57.89293
Outside the city (Nomad starting)
-3235.881592, -6146.751465, 96.834175
V's Mansion
-1341.383545, 1242.970337, 111.100006
Grand Imperial Plaza Mall
-2278.209473, -1992.328613, 20.570023
Unfinished Casino
934.451233, 1458.630981, 242.120010
VB Data Fortress
-1661.448242, -1869.755859, 54.992889
River BD School
-6491.909180, -3167.271240, 57.558006
Monorail Tunnel
-1663.618774, -1867.443726, 54.990150
Konpeki Tower
-2229.413818, 1769.449707, 21.000000
Konpeki Tower Penthouse
-2220.772705, 1765.388916, 308.000000
Konpeki Tower - V Suite
-2202.186035, 1783.184204, 163.000000
Clouds
-625.404236, 794.564392, 132.252228
Embers
-1795.816162, -526.988647, 74.241196
Atlantis
-753.868530, 1107.427612, 61.000000
Badlands Tunnel
-1255.622437, 126.991272, -43.753677
Badlands Tunnel Entrance
185.345749, 2365.449707, 67.081177
Petrochem Off-limits area
-118.046112, -486.535583, 7.296860
Arasaka Tower Abandoned area
-1475.830200, 161.548401, 208.637604
Arasaka Tower Jungle
-1449.256470, 118.300171, 321.639038
Arasaka Tower Upper Atrium
-1390.497559, 162.406921, 388.347961
Arasaka Tower CEO level
-1437.788208, 157.247620, 565.346008
Arasaka Tower CEO office
-1447.286621, 73.579651, 568.946045
Arasaka Tower Unlisted levels
-1428.207520, 95.437912, 543.348022
Arasaka Tower Unlisted temple
-1383.655518, 118.832474, 542.696289
Arasaka Tower Counter-intel
-1442.981689, 139.817459, 141.996506
Arasaka Tower Underground
-1376.191528, 143.706009, -26.648010
Arasaka Tower Boring Machine
-1447.010010, 40.182648, -36.814171
Arasaka Mikoshi Mainframe
-1448.108398, 149.156219, -27.652016
Arasaka Orbital Station
4743.650879, -1091.755127, 1310.439575
Johnny interrogation room
-1389.446533, 141.266556, -139.361572
Config file
Description of all the configuration variables available
The config file is generated automatically and manual edits are not recommended. To modify configurations, use the Settings tab in the CET overlay.
For adjustments to fonts and other stuffs not available in the CET overlay, manual editing may be considered.
The config file can be found in: <cet install path>/config.json
The config file is structured with two JSON layers, we use the format <first level>.<second level> to represent the key.
Consider the example JSON snippet below, the key for the base size of the font is noted as font.base_size, which carries a value of 16.0.
Developer
KEY
TYPE
DEFAULT
DESCRIPTION
Font
KEY
TYPE
DEFAULT
DESCRIPTION
Patches
KEY
TYPE
DEFAULT
DESCRIPTION
Deprecated Patches
These are the 0old Cyber Engine Tweaks config file patches for reference.
ARGUMENT
VALUE
DEFAULT
DESCRIPTION
Change font & language setting
A guide on how to change the font and font size for Cyber Engine Tweaks and mods based on Cyber Engine Tweaks. And how to display non-English characters.
false
WIP
developer.max_lines_console_history
number
1000
CET stores a history of console commands, allowing users to easily access previous commands by pressing the up arrow key. This setting determines the number of commands that CET retains in its history.
developer.persistent_console
boolean
true
When true, CET saves your console command history on your disk, so you can access it in future. When false, the history is only kept in memory while the game is running and disappears once you exit the game.
developer.remove_dead_bindings
boolean
true
WIP
"Default"
Check for details.
font.oversample_horizontal
number
3
WIP
font.oversample_vertical
number
1
WIP
font.path
string
""
(empty)
Check for details.
false
Setting this to true will disable async compute, which can increase performance on older hardware.
patches.disable_boundary_teleport
boolean
false
Remove the teleport caused by going beyond the boundary in the game.
patches.disable_vignette
boolean
false
Disable the vignette effect while crouching.
patches.disable_win7_vsync
boolean
false
Disable V-sync for Windows7
false
Setting this to true will disable async compute, which can increase performance on older hardware.
disable_boundary_teleport
bool
false
Remove the teleport caused by going beyond the boundary in the game.
disable_intro_movies
bool
true
Disable the first movies that play at each launch.
disable_vignette
bool
false
Disable the vignette effect while crouching.
disable_win7_vsync
bool
false
Disable V-sync for Windows7
dump_game_options
bool
false
Will dump all options and their default values in the log file.
enable_debug
bool
false
Unlocks the debug menu, use at your own risk!
font_glyph_ranges
string
Check for details.
font_path
string
Check for details.
font_size
integer
13
Set the font size of the overlay and mods.
overlay_key
integer
Key to open the console.
remove_pedestrians
bool
false
Removes most of the pedestrians and traffic from the game. Be careful using this, a save made with this activated will NEVER have pedestrians/traffic anymore!
skip_start_menu
bool
true
Skips the menu asking you to press the space bar to continue (Breaching...)
patches.disable_intro_movies
boolean
false
Disable the first movies that play at each launch.
patches.skip_start_menu
boolean
false
Skips the menu asking you to press the space bar to continue (Breaching...)
patches.minimap_flicke
boolean
false
f you're experiencing flicker with the minimap in the top-right corner of the game, set true. Only change this setting if you are indeed noticing the flicker issue.
developer.dump_game_options
boolean
false
If true, CET will dump all options and their default values in the log file.
developer.enable_imgui_assertions
font.base_size
number
18.0
Set the font size of the overlay and mods.
font.language
patches.disable_antialiasing
boolean
false
Setting this to true will disable antialiasing (TAA), which can increase performance on older hardware but looks horrible.
patches.disable_async_compute
disable_antialiasing
bool
false
Setting this to true will disable antialiasing (TAA), which can increase performance on older hardware but looks horrible.
If Cyber Engine Tweaks isn't working, here's what you can do
If you are on Linux/SteamDeck, make sure to follow this guide to install the right .dll overrides before reading on.
You need VisualC >= 14.40.33810.0 . Download it from the official Microsoft website ()
If your game is pirated, .
If you're experiencing performance issues, check
If you are experiencing crashes caused by CET, try running Cyberpunk in
If you can't open your overlay, check
If your CET just stopped working (without a game update) or if you've been sent here to do a clean install, see below how to
For any other issues, read .
General troubleshooting
Before trying anything else, please make sure that your Windows and your graphics driver are up-to-date – this actually helps in around 50% of all cases. If you need instructions, you can find them in the red box under the general troubleshooting guide's section.
Step 0: Go to your install directory
Go to your Cyberpunk 2077 game directory, since all paths given in this guide will be relative to that folder.
TL;DR:
CET is installed to bin\x64\plugins\cyber_engine_tweaks
The log file is bin\x64\plugins\cyber_engine_tweaks\cyber_engine_tweaks.log
Example:
Step 0.5: Update your game and the mod
Each version of CET is compatible with exactly one game version. Nobody keeps track of those other than "the most recent ones work together".
For that reason, the Redmodding Discord can only support you the most recent version.
If there's a mismatch, then you can find a warning in the following file:
If you don't have that file, proceed to Step 2.
Step 1: Check the install folder
Go to your Cyberpunk 2077 and check the following subfolder:
It should have at least the following files:
If you do not have these folders, then CET isn't installed correctly. Head to and start with step 3.
Step 2: Check for a log file
If everything looks okay in step 1, check if you have a file cyber_engine_tweaks.log inside the cyber_engine_tweaks folder from the previous screenshot.
You don't have a log file
No log file means that CET isn't starting up.
The easiest fix is to .
If you did that and it didn't help, check your antivirus. Most likely, it is protecting you from scary things like Cyber Engine Tweaks. Disable it.
If that didn't help either, update everything - Windows, your drivers, etc. You can find links and instructions in the red box on the .
You have a log file
If you do have it, you can open it and try to make sense of the error message. You can find more information on that , or find help in the #cet-suppport channel on our .
Reinstall CET
Uninstalling (the full game or just the mod via Vortex) can leave files behind, which will fuck things up for you after a reinstall. This section tells you how to avoid that.
If you are using Vortex, turn it off (it will get angry otherwise)
Complete either of the following steps inside your :
rename bin/x6/plugins to plugins_
Reset your keybind
Find the file \bin\x64\plugins\cyber_engine_tweaks\bindings.json and delete it.
Start the game.
You should now see a popup asking you to bind a key. Otherwise, read on.
I can't bind a key
If you do not see the popup at all, or do a .
Click into the "Binding..." field.
If that doesn't help, make sure to turn off all your overlays (Discord, Steam, Microsoft Game Bar, Random Useless Bloatware) or start Cyberpunk in the Windowed Borderless mode.
Microstutters and Performance
If you're experiencing performance issues with CET, first make sure to as per the instructions to rule out side effects from old files.
If that doesn't make the problems go away, make sure to update Windows and your graphics driver as per the red box under Troubleshooting's section.
If that doesn't help, you can find us in #cet-support on the . Please note that people there will first suggest everything else from this guide, so you might as well get it out of the way first.
Crash to Desktop on Alt+Tab
Make sure to update Windows and your graphics driver as per the red box under Troubleshooting's section, as this is the only chance you have of getting rid of your crashes.
This is a known issue with AMD cards, and it's not something the CET developers can fix. Everyone who could fix it is informed, but such things take time. If you're on an AMD card, you can try running your game in Windowed Borderless mode. Otherwise, you just have to live with the crashes.
Frequent Issues and Solutions
I receive an error saying 'Unknown Version'
Please ensure the following:
If you have modified your game's .exe file yourself, the mod will not work - to undo this, delete the file and verify your game through GOG, Steam or Epic to download a fresh copy of the newest exe.
Update your game. You are using a patch that is not supported.
Only current versions are supported. (current version is 1.6)
You used the old version of the mod and still have the old files installed. Delete bin/x64/plugins/ and reinstall the mod.
No log file appears in bin/x64/plugins/cyber_engine_tweaks/
Install - if nothing happens, please make sure all of your overlays and monitoring programs are disabled. There is a list of known programs that cause issues below. If you find one not on the list, contact Arsenic_Touch via the discord.
I don't have a config file in bin/x64/plugins/cyber_engine_tweaks/
Cyber Engine Tweaks no longer comes with a config file, one is generated when you first launch the mod.
The CET window will not close.
When first launching cyber engine tweaks, it will prompt you to pick a keybind. Tilde is no longer the default. Keyboard input is blocked until a keybind is chosen. If you do not see the pop up, look below for further troubleshooting steps.
When I press the key to show the console, I only see the cursor!
Certain programs conflict with the hook that Cyber Engine Tweaks use to display the console - to avoid this, disable any software with overlays that may impact the mod (some examples below). This includes crashing the game or not launching at all. OBS graphics-hook32.dll and graphics-hook64.dll can also interfere. Do a search of your windows files to see if you have a program running them. For rivatuner, you can also open the Global file with notepad++, which is located in RivaTuner Statistics Server\ProfileTemplates and add cyber_engine_tweaks.asi to the end of the decimal in the line: InjectionDelayTriggers
Cyberpunk crashes after the intro video when using CET 1.14
Open Windows Security
Go to Apps & Browser control on the left tabs
Click Exploit protection settings Under the Exploit Protection section
Credit to discord user @rachmanov1c @OrBy
The mod isn't working with my version of the game!
Please verify that:
Your version of Cyberpunk is compatible with the newest release on GitHub or Nexus (this can be seen in the menu, underneath "Quit Game")
You have the most recent version of the mod from or
The has been followed correctly
If installed through vortex and your game won't launch.
Make sure cyber engine tweaks and your mods are installed with hardlink If hardlink doesn't show up under vortex, make sure the Vortex Mods folder is on the same partition as the game mods folder. This explains it .
Make sure you're using the most up to date vortex plugin for cyberpunk 2077.
Check the channel on the discord for the latest information.
The prompt to choose a keybind doesn't appear and or pressing the chosen keybind does not bring up the mod.
There are six possible solutions to this:
Ensure your game is in - Cyberpunk will usually make itself the topmost application on your screen if in fullscreen.
Ensure you don't have any or monitoring software running such as Rivatuner, Fraps, etc.
Make sure your game is up to date and you are using the latest version of Cyber Engine Tweaks and that you installed it properly. (do a clean install by deleting the plugins folder, LICENSE, global.ini, version.dll files if you are running into a problem)
I forgot the keybind to bring up the overlay for CET.
Delete the bindings.json file located inbin/x64/plugins/cyber_engine_tweaks/ and start your game, the overlay will to choose a new keybind should come up. If it doesn't, check the known list of programs that can interfere.
I can bring up the CET overlay but my image is frozen on intro videos
If you see in your log that your game is freezing on CRender and you have problem like this you should try steps provided below.
1. If you are using mod manager disable CET temporarily, if you are not using mod manager then follow guide.
2. Launch the game without CET and disable FSR/DLSS
3. Install/Enable Cyber Engine Tweaks and launch the game, the problem should be gone.
Submitting an issue
Please ensure you attempt deleting and reinstalling the mod before submitting an issue! Alternatively, . Additionally, please check to ensure your issue has not already been reported!
If you cannot find your problem listed, with the following:
Your configuration file
Your Cyber Engine Tweaks version and your Cyberpunk 2077 version
Your log file
Your keybind is stored in bin\x64\plugins\cyber_engine_tweaks\bindings.json
or
delete the file bin/x6/plugins/cyber_engine_tweaks.asi
move the folder bin/x6/plugins/cyber_engine_tweaks out of plugins(e.g. your Desktop). Do not delete it yet.
Optional: Restore your mods and/or settings
Now that CET works, find the old directory from step 2. Move the following files/folders:
Mods: the directory mods from the old cyber_engine_tweaks folder
Settings: The .json files directly inside cyber_engine_tweaks
Optional: delete the old folder (or leave it, it's your diskspace)
That's it! You're good to go!
Do a repair on your installation with no other mod files installed (redscript, cet, et cetera) then install CET as you normally would and check the log file. If it still isn't working, uninstall cyberpunk 2077 and do a complete wipe of the install folder.
In the Systems Settings tab locate Randomize memory allocations (Button-up ASLR) and High-entropy ASLR and change their settings to Use default (On).
Restart your computer.
You have verified that the log found in bin/x64/plugins/cyber_engine_tweaks/cyber_engine_tweaks.log is 'last modified' at the same time and date as your most recent attempt to launch the game
Remove all previous mods in the mods folder and try to launch the game. If it works, add your mods back one by one until you find the one that breaks CET. Some mods can break CET completely or change the overlay colour if they are not up to date.
Run the game as administrator. (this works for some people where other methods have failed)
Check to make sure your antivirus software is not removing or blocking cyber engine tweaks.
TweakDB.CreateRecord, TweakDB.CloneRecord, and TweakDB.DeleteRecord now support TweakDBID as a parameter type
Changes and fixes
Updated usedhashes.kark to the new URL
Moved to OpenResty Lua JIT
1.19.5 - 05/04/2022
Support for patch 1.52.1 (made up name, they didn't bother to name it AGAIN)
1.19.4 - 22/03/2022
Support for patch 1.52
1.19.3 - 02/03/2022
Changes and fixes
Fix crash on Windows 7.
Fix LoadTexture overwriting the previously loaded texture.
1.19.2 - 28/02/2022
Support for patch 1.5 hotfix 2
Added
ImGui.LoadTexture(string path) returns a texture loaded from an image on disk in the mods' directory.
ImGui.Image(texture) displays a texture loaded with the LoadTexture function.
Full Api is as follows, note that you may omit parameters after texture and default values will be used (Texture texture, ImVec2 size, ImVec2 uv0, ImVec2 uv1, ImVec4 tintColor, borderColor)
Changes and fixes
Added stb to load images.
Fixed bad screen skip fix.
1.19.1 - 19/02/2022
Support for patch 1.5 v2
Changes and fixes
Changed the archive hashes to use the wolvenkit KARK files for TweakDB editing
red4ext updated to 1.3.1
1.19.0 - 16/02/2022
Support for patch 1.5
Changes and fixes
red4ext updated to 1.3.0
mimalloc updated to 2.0.3
sqlite3 updated to 3.37.0+200
Special thanks to WopsS, psiberx and Sombra for their help with this patch!
1.19.0-rc2 - 16/02/2022
Known issues
exEntitySpawner does not work.
No pedestrian patch is not tested.
Changes and fixes
Fix cursor not getting locked to the game.
Fix skip start screen patch not working.
1.19.0-rc - 16/02/2022
Support for patch 1.5
Known issues
exEntitySpawner does not work.
No pedestrian patch is not tested.
Feel free to tell us any other issue that may arise on github/discord.
Changes and fixes
mimalloc updated to 2.0.3
sqlite3 updated to 3.37.0+200
1.18.3 - 10/02/2022
Changes and fixes
Improve the d3d12 hook to fix a crash when using ReShade < 5.
1.18.2 - 09/02/2022
Changes and fixes
Improve the d3d12 hook to avoid conflicts with other overlays.
1.18.1 - 15/12/2021
Contains: and
Changes and fixes
Fixed random crashes when overridden method has a script reference parameter.
Fixed random crashes when working with game structs.
Fixed random crashes for very frequently called overrides (such as GameObject.OnGameAttached and GameObject.OnDetach
Added
Added the ability to add new free flats to TweakDB.
1.18.0 - 4/12/2021
Contains: , , and
Changes and fixes
Fix bad allocation causing crashes when using some RTTI types
When using Override() the handler receives the original function (or next in the override chain) as the last parameter
The wrapped function can be called multiple times
If any of the overrides fail then the entire override chain also fails
Observers can be called before and after the target function using ObserveBefore() and ObserveAfter()
Observe() is an alias for ObserveBefore()
All observers are guaranteed to be called even if overrides and other observers fail
It's possible to observe and override static class methods
Full name should be used when overriding a scripted static method
Use weak handle for self in overrides. This should decrease the number of unreleased references and make CET less dependent on garbage collection.
Reuse overridden functions on mods reload. This fixes a potential issue with the native function registry, which has a hard limit on the number of registered functions.
Support out params in overrides.To properly handle out params in overrides:
Added
Added support for mods deployed as a symlink for the mod directory
Added Lua function to check if the mod archive is installed:
Use FromVariant(variant) to extract the value
Use ToVariant(value) to pack the value when the type is unambiguous
Use ToVariant(value, type) when the type is ambiguous or you wanna force the type
The type of the array is resolved from the first element when possible
Added event for early TweakDB changes:
1.17.0 - 2/10/2021
Contains: , , and
Changes and fixes
Fixed directx12 hooking not working when overlays were present.
Fixed symlink deployment with Vortex.
Drop second implementation of Scripting::ToRED() which was very outdated. This was limiting what overridden functions can return.
Will output
Added
Stricter check of the passed context when calling the RTTI function. Prevents unwanted crashes when invalid value passed as self / this. In particular, it prevents crashes when a dot is accidentally used instead of a colon.
Support for ISerializable strong and weak references. This opens access to some new classes, but not all of them.
Workaround for parameterized struct constructor. Previously, fields of a reference type could be corrupted right after construction.
Support of nulls for strong and weak references.
Assignment example:
Parameter example:
IsDefined helper function as in redscript. Checks if reference is not null and valid. Can be used on game object's field and lua variable.
EnumInt helper function as in redscript.
Support for CRUID type.
Support for gamedataLocKeyWrapper type.
1.16.4 - 14/09/2021
Support for patch 1.31
Contains:
Changes and fixes
Updated to Imgui 1.84.2
1.16.3 - Don't remember when
Support for patch 1.30 second edition.
1.16.2 - 27/8/2021
Contains:
Changes and fixes
Fix disappearing footsteps (1.16.1 regression).
Alternative syntax for CName and TweakDBID conversions without .new()
Direct access to global functions.
Throw Lua errors from RTTI calls as the Lua script will do.
Will print the full callstack in the log:
1.16.1 - 23/8/2021
Changes and fixes
Fix channel logs not printing the message.
Added a new channel "DEBUG" that always prints even when game logs are disabled.
Re-added TweakDB printing.
1.16.0 - 20/8/2021
Support for patch 1.30 - huge thanks to everyone who helped with this and all testers!
Contains: , , , and
Changes and fixes
Fix crash when calling functions that have optional parameters not defaulted.
Fix crash when using RegisterInputListener from an observer.
1.15.0 - 8/8/2021
Contains: , , , , , , and
Script API
Whitelisted collectgarbage to let scripts force release game references.
Added exEntitySpawner to spawn entities easily
Changes and fixes
Fixed a crash that would occur on machines without ASLR enabled by enabling LuaJIT's GC64 option.
Fixed nested RTTI calls that would crash the game due to memory release of the previous call's memory.
Fix the disable anti AA and async compute patches.
1.14.0 - 17/06/2021
Contains: , , , , ,
Script API
All game classes are directly accessible by name. For example, entEntityId, PlayerPuppet.
All game enums are directly accessible by name. For example, gamedataStatType.BaseDamage, gameGameVersion.Current.
Added WorldFunctionalTests
Added Imgui.GetStyle()
Added support for ResourceAsyncReference. Allows editing of TweakDB props of that type by the mods.
Changes and fixes
Fixed disappearing footsteps issue.
The issue still can occur if the mods do not properly release the player reference.
The GetMod() is only available after onInit
Internals
Global fallback table is used now for all mod environments. No need to whitelist what's defined there.
Aliases like Game['GetPlayer'] = Game['GetPlayer;GameInstance'] aren't needed in autoexec.lua. All global and class functions are automatically resolved by short name now.
Added
Patch for the Minimap flicker
1.13.0 - 28/04/2021
Support for patch 1.22
Fixed
Crash when using TweakDB:Update in an Observe/Override callback
Direct3d12 command queue could be null sometimes
Error logging from Observe/Override callbacks
Added
Strings can now be implicitly cast to a TweakDBID when the scripting framework expects a TweakDBID
1.12.2 - 14/04/2021
Support for patch 1.21
Fixed
Lua scripting errors with functions returning some values with out params
GameOptions.Toggle() now works
Fix falsy "Unknown error" when calling a global that returns nil
Added
Equality comparison to some types (Vector3, Enum, TweakDBID,...)
Concatenation for TweakDBID
1.12.1 - 04/04/2021
Fixed
Regressions with GameOptions
Wrong version info returned back by GetVersion()
Problems with Console widget history
Added
Modal popups for unsaved changes into Bindings and Settings widget
Modal popup on first launch asking user explicitly to bind some hotkey for toggling Overlay
Option to enable removing of dead binds (default is on)
Changed
Nicer formatting of headings inside Bindings widget (replace characters that are not alphanumeric by space and autocapitalize each word)
Reworked Settings menu (options are now split into two categories - Patches and Dev)
Reworked Bindings menu (separated hotkeys and inputs into two categories)
1.12.0 - 29/03/2021
Added support for patch 1.2.
Fixed
os.remove and os.rename were not working properly.
The debug menu patch would not show the menus.
Fixed dofile, loadfile and loadstring.
Changed
Key bindings were improved.
Support for scroll wheel.
registerInput for single inputs. This handler is similar to registerHotkey, but function now takes one boolean argument denoting if input was pressed/released.
Added
Re-added the SMT patch for AMD CPUs that did not get a performance boost after CDPR's patch.
Added Lua's bit32 library.
TweakDB additions:
1.11.4 - 18/02/2021
Fixed
Fix memory allocation errors due to missing argument.
Fix Observe/Override sometimes affecting scripts when they shouldn't.
1.11.3 - 17/02/2021
Fix crash when using multiple mods.
1.11.2 - 17/02/2021
Fixed
Crash on game exit when a reference had not been garbage collected by the lua vm.
Missing enum value CellPadding in Imgui Lua (Pull Request: ).
Crash when using Override/Observe on pure script functions.
Changed
Memory optimization for calls.
Replaced the hacky thread safety used for the Lua VM with TiltedCore's Lockable<T>.
1.11.1 - 15/02/2021
Added
API changes to support Imgui 1.81 and added missing ColorButton overloads.
Override has now 2 overloads to simplify usage, this will completely remove the original function or add one if it doesn't exist:
Fixed Override so that it can override at runtime after scripts have been loaded.
Revert Lua caching of functions as the new override method will work regardless.
Fixed
Fix game crash when a script used "require" on a malformed file.
1.11.0 - 13/02/2021
Added
Override function to either listen to a function or to replace a game function. Despite its name it can also be used to extend a type by adding a new function.
Usage is as such:
The first parameter is the class type, second the full name of the function, the third is the short name (usually they are the same), the fourth boolean is used to specify if this is a replacement of the function or not, if set to true it will replace entirely the original function, if set to false, your function will be called before the original function is called. The last parameter is your handler function, note that the parameters are passed according to the RED script definition.
Removed
Telemetry, the experiment gave us the data we wanted, obviously a lot of people use the mod and we are very happy about that! We are sorry this caused so much drama, it wasn't the intention and quite frankly we still don't really understand why.
Changed
Calling RED functions used to be cached, given that functions can be overridden at any time the cache has been removed, it's a bit slower but shouldn't be visible in the real world.
1.10.3 - 12/02/2021
Using the up and down arrows in the console now retrieves the command history
1.10.2 - 07/02/2021
Added Telemetry so we know how many people use CET (can be disabled in settings), note that we do not store any information we just count the number of players
1.10.1 - 06/02/2021
Fix TweakDBID issues with large arrays
Fix TweakDBID crash when using specific functions
1.10 - 05/02/2021
Changed
Updated to game version 1.12
Updated RED4ext.sdk to the latest
Proper sandboxing ():
Each mod is (right now) assigned sqlite3 database implicitly, accessible through db lua object (will be changed later to on-demand through info in metadata file)
Introduced proper sandbox with LuaSandbox helper class
Bytecode cannot be loaded now (native modules included)
More ImGui stuff(, , , ):
Enabled ImGui keyboard navigation. (ctrl + tab to switch window, arrow keys to navigate)
Removed the deprecated power argument in Drag and Slider widgets, replace it with the newer ImGuiSliderFlag (breaking change)
TweakDB binding ()
TweakDB:GetFlat(...)
TweakDB:SetFlat(...)
TweakDB:GetRecord(...)
1.9.6 - 30/01/2021
Changed
Major vulnerability in the game's save loader fixed
1.9.5 - 28/01/2021
Changed
Updated to game version 1.11
Updated RED4ext.sdk to the latest
Updated to spdlog 1.8.2
1.9.4 - 26/01/2021
Changed
Replaced pattern search with much faster library
Fixed
Fix issue when resizing game window (eg. resolution change in Options)
Fix issue causing game window to stop rendering and freeze on last frame
Fix ImGui.CalcTextSize overloads (now, second parameter is removed from all, as it did not make sense for Lua anyway)
1.9.2 - 23/01/2021
Added
Added jsonsupport to Lua
1.9.1 - 23/01/2021
Added
Added support for the latest patch 1.10
UI with settings will now ask you for a console key on first launch, you can edit it later
Mods can now request hotkeys via registerHotkey, the user can pick what key they want to use in the menu
Fixed
Scripting is now handling memory correctly, calling Game.GetPlayer() every frame is fine now
Game doesn't crash when exiting anymore
Removed
dofile is now deprecated, use only mods please, it will be removed entirely in the next update
on game reload).
Fixed random crashes for hotkeys and inputs (for example, binding the mouse wheel had a very high chance of causing crashes).
Fixed potential issues when CET mods that modify TweakDB are used with TweakDBext mods at the same time.
Accept all params in the handler
Don't pass out params to the wrapped function
Return all results from the handler
Fix gamedataTDBIDHelper helper that behaves the same as gamedataTweakDBInterface.
Sanitize type names to be a valid Lua identifier. This makes namespaced types added by redscript accessible in Lua.
Force garbage collection for overridden functions of inkGameController and it's descendants.
In some cases, there seem to be issues with unreleased instances of inkGameController leading to crashes. This was introduced when we started to properly wrap the context in Handle<>.
Changed the behavior of observers so that all observers will be called even if an override is defined.
Function to add new CNames to the pool
Register global PlayerPuppet.OnAction handler as for pre patch 1.3.
Override function by full name. Allows to observe/override all variants of overloaded function.
Fix for TweakDB default values.
Fix tooltips that contained C format characters and would crash the game.
Improved update hook.
xmake install will now install in the game's directory to make it easier for those installing from source.
Classes can also be accessed by their aliases from redscript. For example, WeaponObject instead of gameweaponObject.
Classes have the conventional .new() constructor. For example, MappinData.new().
A constructor can take an array of properties to create and initialize an object in a single statement. For example, EntityID.new({ hash = 12345 }).
Static methods are accessible from classes using the dot. For example, ScriptedPuppet.IsDefeated(npc).
A static method can be called from an instance if the first parameter is of the same type. For example, vec4:Length() instead of Vector4.Length(vec4).
The overloaded function is resolved based on passed parameters when called by its short name. For example, StatusEffectHelper.HasStatusEffect(target, gamedataStatusEffectType.Overheat).
Partial Variant type support. ToVariant() and FromVariant() are only applicable to classes.
Observe() and Override() now accept both native and scripted type names.
Added Game.GetSystemRequestsHandler() as an alternative to GetSingleton("inkMenuScenario"):GetSystemRequestsHandler().
Added TweakDB:SetFlats
as there is no guarantee that the required mod will be loaded before this event.
Types and functions that rely on RTTI are only available after onInit event to prevent some unwanted crashes and unexpected behavior.
Improved detection of whether the game is running. Prevents more crashes when exiting the game.
Implemented optional parameters support. Prevents some unexpected crashes.
Fixed DumpType("Type") returning empty result.
Fixed crash when accessing properties of invalid Enum, eg. Enum.new('', '').value.
Fixed crash when setting an incompatible value for an object property.
Fixed crash when calling function with out parameters of Enum, CName or TweakDBID type.
Fixed memory leaks when passing strong or weak references to the function.
Fixed memory leaks when invalid parameters passed to the function.
Fixed memory leaks for function results and out parameters of certain types.
Fixed memory leaks when creating new objects.
Fixed memory leaks when setting object properties.
Fixed memory leak for arrays with elements of certain types passed as an argument.
Fixed a crash when passing an incompatible array as an argument. For example, an array of numbers instead of an array of handles.
Fixed memory leak when passing an object instead of an array as an argument. This resulted in a silent crash without calling ResetAllocator.
Fixed inconsistent self and random crashes in Observe and Override.
Reverted Override() to the previous behavior so when the handler fails, the original game function is not called.
Added implicit conversion from Int64/UInt64 to other arithmetic types.
Added type safety checks for Int64/UInt64.
Added recursive freeing of arrays.
Added logging for errors occurred in the module loaded with require(). Should make the transition to the new version less painful.
Added implicit class to strong reference conversion.
Updated RED4ext to latest version.
This fixes the error when trying to use a CName that is None
Redundant Lua environment passing
64bits numbers are now correctly interpreted as numbers by Lua
Return out params from global function the same way as for instance methods
EulerAngles::ToString returning swapped roll and yaw values
SQLite3 database not closing on mod reload
3rd party licences missing
ImGui.TreePop unavailable in Lua
Multiple registerInput handlers unable to be invoked at same time
Conversion of 64-bit integral values from object properties
Scroll wheel failling to register properly
Option to enable ImGui assertions to make sure mods are not breaking something (default is off)
Option to toggle ImGui Diagnostic window (default is off, this option is not preserved after restart!)
onDraw is not called for mods while CET modal dialog is active (including first launch)
First time launch (it should now be more streamlined)
Decoupled config.json from bindings.json (overlay key is now located only inside bindings.json and is left out of config.json)
Overlay key was moved to Bindings menu
Updated TiltedCore to 0.2.2
Lua environment would not be applied correctly to some callbacks.
Lua to RED engine converter now works correctly with nil values and double.
Security issue where scripts could override another script's functions, calling another script is now read only.
IsBound and GetBind added to check if action is bound and retrieve string representation of it.
TweakDB experienced many changes:
All TweakDB functions can now be called with strings instead of TweakDBID. TweakDBID is still accepted.
TweakDB:SetFlat now updates records if it already exists (see SetFlatNoUpdate)
Performance improved.
Lua version changed to 5.1 this can break your mod if you were using post 5.1 language features such as bit operators. This change was done to fix environment issues, we also got a performance boost by switching to LuaJIT instead of the default Lua implementation.
Updated Imgui to version 1.82.
Updated spdlog to version 1.8.5.
Updated sqlite3 to version 3.35.0.
CloneRecord, CreateRecord and DeleteRecord.
GetRecords, obtain a list of records associated with a type.
SetFlatNoUpdate, faster way to set without checking if there is an old record to update. Requires call to TweakDB:Update afterwards to apply changes!
TweakDB editor in the UI.
Supports loading archivehashes.txt.
Can now search through record flats.
Crash when reloading mods using Override/Observe.
Crash when a malformed lua file was loaded with "require".
Lua execution error when a callback used a global variable because environments were not applied.
Fix memory leaks when reloading mods using Observe/Override.
Override(typeName, functionName, function) - both full and short names are set to functionName
Observe has now 2 overloads to simplify usage, this will not remove the original function but will add one if it doesn't exist:
Observe(typeName, functionName, function) - both full and short names are set to functionName
require cache is reset on Reload all mods now
require does not support '.' instead of '/' now (only breaking change, functions the same otherwise)
All pathing is now relative to mod (breaking change, includes all io functions, dofile() and such included)
stripped ImGui, json, io and dofile and such from console sandbox (only needed things left for it in)
Added dir() command for mods to list directory contents
Errors that happen in Game, game class methods,... should now log into proper environment (to console when executed from console, to mod log when executed from mod)
Made the argument open optional in ImGui.Begin(), ImGui.BeginModal(), ImGui.BeginTabItem(), so the close button can be hidden when setting flags.
Added bindings for the new tables widget in ImGui 1.8.0
You can now instantiate game objects with NewObject('class name'), do not expect this to work with every class without any issues
SQLite3 support was added, you can use the entire API at the moment, we are going to remove all open functions in the near future and replace it with a open that can only open a single database linked to your mod
Mods will now log to their own log files, you can also use spdlogto print in your log
-- Get the sticky frag grenade record
sticky_grenade = TweakDB:GetRecord("Items.GrenadeFragSticky")
-- Create a clone of "Items.GrenadeFragSticky" with the name "Items.GrenadeFragStickyNew"
TweakDB:CloneRecord(sticky_grenade:GetID() + "New", sticky_grenade:GetID())
-- Get the new record
sticky_grenade_new = TweakDB:GetRecord("Items.GrenadeFragStickyNew")
-- or
sticky_grenade_new = TweakDB:GetRecord(sticky_grenade:GetID() + "New")
-- manipulate the new record as needed
-- delete record many different ways
TweakDB:DeleteRecord(sticky_grenade_new:GetID())
TweakDB:DeleteRecord(sticky_grenade:GetID() + "New")
TweakDB:DeleteRecord("Items.GrenadeFragStickyNew")
ToVariant(1, "Int32") -- Same numeric value can be a signed integer
ToVariant(1, "Uint32") -- or unsigned integer
ToVariant(1, "Float") -- or float
ToVariant(nil, "handle:PlayerPuppet") -- Null requires a concrete type
ToVariant({ "a", "b", "c" }) -- Auto resolved as "array:String"
ToVariant({ 1, 2, 3 }, "array:Uint32") -- Ambiguous type
print(GetPlayer()) -- Equivalent to print(Game.GetPlayer())
registerForEvent('onInit', function()
Observe('TimeSystem', 'SetTimeDilation', function(self, reason)
if reason.value == 'consoleCommand' then
Game.FloorF('XXX')
end
end)
end)
registerHotkey('TestError', 'TestError', function()
Game.GetTimeSystem():SetTimeDilation('consoleCommand', 0.25, 1.0, 'Linear')
end)
[error] ...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:4: Function 'FloorF' parameter 1 must be Float.
stack traceback:
[C]: in function 'FloorF'
...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:4: in function <...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:2>
[C]: in function 'SetTimeDilation'
...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:10: in function <...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:9>
spawnPosition = Game.GetPlayer():GetWorldTransform()
-- [Simple]
-- Spawn 'Character.Judy' just like prevention system
-- Optionally set appearance to 'judy_diving_suit'
judyEntityID = exEntitySpawner.SpawnRecord('Character.Judy', spawnPosition)
judyEntityID = exEntitySpawner.SpawnRecord('Character.Judy', spawnPosition, 'judy_diving_suit')
-- [Advanced]
-- Spawn base\quest\secondary_characters\judy.ent
-- Optionally set appearance to 'default'
-- Optionally set TweakDB record to 'Character.Judy' (VO/Name/Equipment/etc)
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition)
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition, 'default')
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition, 'default', 'Character.Judy')
-- Some time later...
-- entities are not spawned instantly, FindEntityByID may return nil
judy = Game.FindEntityByID(judyEntityID)
exEntitySpawner.Despawn(judy)