# VS Code

<div align="left"><img src="/files/-MdsJJfMVIeKrIcmoUiX" 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="/files/Fo6htHUvs876VET5VQpe" 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="/files/-MdsJTbtYaGgYVI-4NpG" 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="/files/-MdsJWVc8TNhTQzR9QKh" alt=""></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/cyber-engine-tweaks/resources/vs-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
