Setting up Redscript and VSCode

How to configure your setup

Created by HJHughJanus on github, moved here for better maintainability

1. Install redscript

  1. Download redscript from github:

The zip file will contain the following folders:

- engine
- r6
  1. Extract it directly into your directory, so that the folders merge with the ones already there.

  2. Start the game so that redscript can set itself up.

  3. Check the folder Cyberpunk 2077\r6\logs : if redscript has done its thing, you will now see a file named redscript_rCURRENT.log

You can now put your redscript mods into Cyberpunk 2077\r6\scripts and they will be automatically loaded when the game starts.

2. Setting up VSCode

  1. Download and install VSCode.

  2. After starting it, click on the Extensions icon in the left menu bar:

  1. Search for redscript ide and install the Redscript IDE extension.

  1. Click on the cog menu next to redscript-ide-vscode:

  2. Set up the path to your cyberpunk install in VS Code preferences.

  1. Save the settings

3. Testing the tools

You need to restart VSCode before the redscript language server will start working

  1. Create a mod development folder somewhere (example: D:\Cyberpunk\redscript_modding)

  2. Inside the folder, create a plain text file with a .reds extension (e.g. MyMod.reds)

  3. Open VSCode and click Open Folder, then point it at your mod development folder from step 1

  4. On the left, you should see the file you created in step 2. Open it and paste the following (incorrect) code snippet:

//add field to NPC class
@addField(NPCPuppet)
let testField: bool;
  1. Save the file (Hotkey: Ctrl+S).

  2. You should see an error, because bool should be Bool.

  3. Hover your cursor over the error, you should see something like this:

  1. Correct the code:

//add field to NPC class
@addField(NPCPuppet)
let testField: Bool;
  1. Save again — everything should work now.

If you want to make a redscript mod, you can check out How to create a hook (originally by HJHughJanus on github)

4. Bundle with red-cli

This step is optional. You might find this tool helpful to avoid repetitive tasks.

red-cli is command line interface tool to improve your experience as a scripting modder. It allows you to run commands from a terminal to quickly install your scripts in game folder. It is also convenient to make an archive with your scripts, ready to release to users on Nexus Mod.

You can find red-cli on GitHub to download and install it on your system. You can then follow its README, it should explain everything you need to know to use it.

As an example, lets say your project (Cocktail · v0.1.0) contains the following scripts:

Cocktail/
|-- red.config.json                // Project's configuration, see README.
|-- scripts/
    |-- FruitCocktail.reds
    |-- Utils.reds
    |-- Data/
        |-- Fruit.reds
        |-- Banana.reds
    |-- Services/
        |-- CocktailService.reds
    |-- Extensions/
        |-- PlayerPuppet.reds
        |-- ItemObject.reds

If you run the command red-cli pack in a terminal, it will bundle scripts and output an archive like this:

Cocktail/
|-- Cocktail-v0.1.0.zip
    |-- r6/
        |-- scripts/
            |-- Cocktail/
                |-- Cocktail.reds
                |-- Cocktail.Global.reds
                |-- Cocktail.Data.reds
                |-- Cocktail.Services.reds
                |-- Cocktail.Extensions.reds

It helps quickly prepare your mod to release it. It also reduce the amount of scripts by merging them per module (see module feature). When the code is in the global scope (no module statement), it will merge scripts in <name>.Global.reds, with this example, in Cocktail.Global.reds.

Last updated