> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/scripting-cyberpunk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/scripting-cyberpunk/cyber-engine-tweaks/first-steps/vs-code.md).

# VS Code

<div align="left"><img src="https://1927068511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffwsaoju1TBAUvMpI6NIw%2Fuploads%2FVFQtoRKMODUwmjmIppLL%2Fcet-vscode-demo-115.gif?alt=media&amp;token=4d2d2239-8ba1-4a6c-ab0e-1641e4a5b09e" alt=""></div>

## 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")`&#x20;
* Contextual suggestions for default values and predefined sets

## Installation

### CET typedef

1. Download and extract the [Cyber Engine Tweaks Lua Lib](https://github.com/psiberx/cp2077-cet-typedefs/releases/download/v211124/cet-lua-b-1.18.0-211124.zip).
   * The lib files linked above is not the newest version.
   * You can join the [Cyberpunk 2077 Modding Community discord server](https://discord.gg/redmodding) and then visit [this message](https://discord.com/channels/717692382849663036/795037494106128434/1160542144528912524) to download the newest version  (CET 1.27 / Patch 2.01 Typedefs).
   * You can alos check the pinned messages in the [#cet-lua-scripting channel](https://discord.com/channels/717692382849663036/795037494106128434) for any future update.
2. Install the [Lua by sumneko](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) extension.
3. Locate settings.json in VS code
   * Ctrl + Shift + P
   * `C: > Users > (yourname) > AppData > Roaming > Code > User > {} settings.json`

<figure><img src="https://1927068511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffwsaoju1TBAUvMpI6NIw%2Fuploads%2FE1Bqibv17nVGFM0dLflf%2FScreenshot%202024-03-08%20162816.png?alt=media&amp;token=d3b78b69-ce87-4a2d-9c3a-17faf7827cfd" alt=""><figcaption><p>select JSON, not UI</p></figcaption></figure>

4. Add next settings to the `.vscode\settings.json` or in the Settings GUI: &#x20;
   * NOTE: ensure commas occur after every line

```json5
     "Lua.runtime.version": "LuaJIT",
     "Lua.workspace.preloadFileSize": 15360,
     "Lua.workspace.library": [
         "c:\\path\\to\\cet-lua-lib",
     ], 
```

5. 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 [Nats-ji/CET\_ImGui\_lua\_type\_defines](https://github.com/Nats-ji/CET_ImGui_lua_type_defines) and then follow the same installation process in [#cet-typedef](#cet-typedef "mention") 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`:

```lua
---@param request PerformFastTravelRequest
Observe("FastTravelSystem", "OnPerformFastTravelRequest", function(request)
    -- Now request object has type and suitable for code completion
end)
```

<div align="left"><img src="https://1927068511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffwsaoju1TBAUvMpI6NIw%2Fuploads%2FVBwDCXeYrDXu0yHNXlRO%2Fcet-vscode-param.png?alt=media&amp;token=7c049eab-6f57-44a1-9bfe-6ffb2be2f2fd" alt=""></div>

#### Unresolved type

If type of some variable cannot be resolved or ambiguous you can force the type with `@type` annotation:

```lua
---@type ScriptedPuppet
local puppet
```

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

<div align="left"><img src="https://1927068511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffwsaoju1TBAUvMpI6NIw%2Fuploads%2FOuORQSpkwJLUihXFTiNG%2Fcet-vscode-generic.png?alt=media&amp;token=449a3a03-25f8-4952-8b11-e60eedd8f7eb" alt=""></div>
