Skip to content

Compilation

Scrivener07 edited this page Jun 26, 2019 · 10 revisions

The Papyrus Language extension provides features related to source code compilation.

Do you have a complicated build system, or something simpler? VS Code will accommodate in any case. There are many ways to compile Papyrus scripts with VS Code. Read more about the Papyrus Compiler.

Table of Contents

Using the Project Explorer

The Project Explorer for Papyrus provides compilation support.

Read more about the Project Explorer.

Using the VS Code Integrated Terminal

The VS Code Integrated Terminal provides a Command Line Interface (CLI) inside the editor.

When an integrated terminal is opened, it will initially start with a current working directory at the root of your VS Code Workspace. This can be convenient as you don't have to switch windows or alter the state of an existing terminal to perform a quick command-line task.

To open the terminal:

  • Use the Ctrl+` keyboard shortcut with the backtick character.
  • Use the View > Terminal menu command.
  • From the Command Palette (Ctrl+Shift+P), use the View: Toggle Integrated Terminal command.

The compiler may be executed using the CLI in many ways. Some examples are single files, directories, and Papyrus Projects. Read more about the Papyrus Compiler and its arguments.

CLI for Single Files

The CLI commands for single file compilation.

Fallout 4
<PapyrusCompiler.exe> <psc> -i="<scripts folder>" -o="Data\Scripts" -f="Institute_Papyrus_Flags.flg"

CLI for a Directory

The CLI commands for directory compilation.

Skyrim
<PapyrusCompiler.exe> <folder> -i="<scripts folder>" -o="Data\Scripts" -f="TESV_Papyrus_Flags.flg"

CLI with a Papyrus Project

The CLI commands for Papyrus Project compilation is only supported in Fallout 4.

<PapyrusCompiler.exe> <ppj>"
  1. Copy the full file path string to a Papyrus Project intended for compilation.
  2. Open the VS Code Integrated Terminal and set the current working directory to the Papyrus Compiler folder.
  3. Execute the "PapyrusCompiler.exe" where the first argument is the file path of a Papyrus Project (*.ppj).

Execute

<PapyrusCompiler.exe> "the\path\to\your\project.ppj"

Using VS Code Tasks

A VS Code Task is a special workspace file ...\MyWorkSpace\.vscode\tasks.json. A task may be used to execute the compiler, call a batch file, or start any other process.

Compile File Task

For single file builds the compiler can be called directly with arguments from a task. The example below compiles a single script called MyScript.psc which is located Skyrim\Data\Scripts\Source\User. The compiled script will be output to Skyrim\Data\Scripts\Source\User_Output.

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Papyrus Compile File (Skyrim)",
            "group": "build",
            "type": "process",
            "command": "${config:papyrus.skyrim.installPath}\\Papyrus Compiler\\PapyrusCompiler.exe",
            "options": {
                "cwd": "${config:papyrus.skyrim.installPath}\\Papyrus Compiler"
            },
            "args": [
                {
                    "value": "${config:papyrus.skyrim.installPath}\\Data\\Scripts\\Source\\User\\MyScript.psc",
                    "quoting": "strong"
                },
                {
                    "value": "-import=${config:papyrus.skyrim.installPath}\\Data\\Scripts\\Source\\User;${config:papyrus.skyrim.installPath}\\Data\\Scripts\\Source",
                    "quoting": "strong"
                },
                {
                    "value": "-output=${config:papyrus.skyrim.installPath}\\Data\\Scripts\\User_Output",
                    "quoting": "strong"
                },
                {
                    "value": "-flags=TESV_Papyrus_Flags.flg",
                    "quoting": "strong"
                }
            ],
            "problemMatcher": []
		}
    ]
}

Compile Directory Task

For directory builds the compiler can be called directly with arguments from a task.

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Papyrus Compile Directory (Fallout 4)",
            "group": "build",
            "type": "process",
            "command": "${config:papyrus.fallout4.installPath}\\Papyrus Compiler\\PapyrusCompiler.exe",
            "options": {
                "cwd": "${config:papyrus.fallout4.installPath}\\Papyrus Compiler"
            },
            "args": [
                {
                    "value": "${config:papyrus.fallout4.installPath}\\Data\\Scripts\\Source\\User",
                    "quoting": "strong"
                },
                {
                    "value": "-import=${config:papyrus.fallout4.installPath}\\Data\\Scripts\\Source\\User;${config:papyrus.fallout4.installPath}\\Data\\Scripts\\Source\\Base",
                    "quoting": "strong"
                },
                {
                    "value": "-output=${config:papyrus.fallout4.installPath}\\Data\\Scripts",
                    "quoting": "strong"
                },
                {
                    "value": "-flags=Institute_Papyrus_Flags.flg",
                    "quoting": "strong"
                },
                {
                    "value": "-all",
                    "quoting": "strong"
                }
            ],
            "problemMatcher": []
        }

    ]
}

See Also

Clone this wiki locally