Introduction
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 this and understand what is expected of you and your mods.
First of all we advise that you do not use keyboard events except in the following cases:
- You need a quick input (for example pressing the key triggers a super power that kills the target)
- Your mod is huge and you need a key to get it up (for example a multiplayer mod)
And here are some examples of when not to bind a key:
- To run a few lines of code that are not time sensitive (upgrading all items to Legendary)
- To open the user interface of your mod (prefer adding a menu to the toolbar)
- To override game inputs
All mods must be located in
bin\x64\plugins\cyber_engine_tweaks\mods\
otherwise they will not be loaded. You need to create a directory for your mod, we suggest you name it in snake case for uniformity (see the example below). In your directory you need to create a file
init.lua
that will contain your initialization code. This is the only file that will be automatically loaded, it is mandatory that you name it init.lua
exactly.In
init.lua
you can register for events that will get called automatically, onInit
, onShutdown
, onUpdate
, onDraw
, onOverlayOpen
, onOverlayClose
via the registerForEvent(name, callback)
function.Let's assume we wanted to create mod called
Is Player Naked?!
that prints every frame if the player is naked or not. We would create a directory called is_player_naked
and create an init.lua
file in it. You should have the fullpath bin\x64\plugins\cyber_engine_tweaks\mods\is_player_naked\init.lua
we can now add the following code in init.lua
.-- You can use this object to store any type of variables.
IsPlayerNaked = {
Player = nil
}
registerForEvent("onInit", function()
IsPlayerNaked.Player = Game.GetPlayer()
end)
registerForEvent("onShutdown", function()
IsPlayerNaked.Player = nil
end)
registerForEvent("onUpdate", function(delta)
print("Is the player naked this frame? " .. tostring(IsPlayerNaked.Player:IsNaked()))
end)
You can either start the game or open the console and click on the button dedicated to reloading scripts.
Last modified 1yr ago