Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Ready-to-paste CET code
You can also find example mods in the wiki's github repository
A collection of LUA scripting utilities to make your life easier
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 onDraw callback.
Default tooltip on a button.
To customize the tooltip window use BeginTooltip
and EndTooltip
.
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.
A list of mods that you may find helpful for making an ImGui window
CET Overlay Window Builder Tool:
FellowImGui (online tool):
Prints one or multiple objects into
Prints one or multiple objects into file
Handle table
with indentation
Handle boolean
, nil
, string
and other classic types
Parse userdata
via GameDump()
or Dump()
if possible
Parse CName
via NameToString()
if possible
Prints to , similar to function.
Write in file. eg, <
>/mods/my_mod/my_mod.log
. Similar to .
Access and write tables using dot "." notation, also known as "flat path". Similar to TweakDB Flat logic but for any kind of LUA table.
All code examples below use this predefined table data. Note that items
is an associative object and elements
is a sequential table.
Get value
Has value
Set value
Insert sequential table value
Delete value
Do stuff later without blocking
Published: Feb 18 2024 by Last documented edit: Feb 18 2024 by
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:
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.
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.
The callback is defined once.
The callback is defined every time cron runs.
To pass arguments to your callback function, you pass them as arguments to cron:
Execute the callback after X seconds
Executes a function every X seconds.
The function will run forever unless you stop it!
You can pause a timer by passing its reference to cron: