Papyrus Compiler Reference

From the CreationKit Wiki
Jump to navigation Jump to search

What is the compiler?[edit | edit source]

The compiler is a program that takes the script file you write (the .psc file) and converts it to a format that the game can understand (the .pex file). During the process it will check your scripts for a wide range of errors, and report them to you. All Papyrus scripts must be compiled before they can be used in the game.

Running the compiler[edit | edit source]

In the Creation Kit[edit | edit source]

The easiest way to run the compiler is to have the Creation Kit do the compilation for you via the Papyrus Script Manager. Simply right-clicking on a script and selecting "Compile" will compile the script and show you any errors reported.

The Creation Kit uses the following command line to build scripts (see below):

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

Outside the Creation Kit[edit | edit source]

Power-users may want to execute the compiler via the command line, or via a batch file, or even through your favorite text editor (we provide setup directions for Sublime Text and Notepad++). In order to do so, you'll want to run the PapyrusCompiler.exe inside the "Papyrus Compiler" folder, which can be found in the location where you installed the editor. Of course, you'll need to specify a series of command line arguments to tell it what to do. If you run the compiler without any command line parameters, or with erroneous ones, it will spit out a set of help text to remind you what they are.

The very first thing you pass to the compiler is the name of the script (or folder, if you're using the -all flag) to compile.

The common command-line parameters are listed as follows (there are others, but most users will not need them):

-import="<folders>"
-output="<folder>"
-flags="<file>"
-all
-quiet

Import[edit | edit source]

-import="<folder 1>;<folder 2>;<folder 3>"
-i="<folder 1>;<folder 2>"

This command line parameter specifies a list of folders that the compiler will look in for other scripts and the flag file. You'll want to at least point this at the folder that contains all the game's base scripts. Multiple folders are separated by semicolons.

If you happen to have multiple import sources, make sure that none of these have scripts with matching names. Only the first occurrence will be imported, every other source of the same name is ignored.

Output[edit | edit source]

-output="<folder>"
-o="<folder>"

This parameter specifies the output folder for the compiled files. You'll almost always want this to be your game's "Data/Scripts" folder.

Flags[edit | edit source]

-flags="<file>"
-f="<file>"

This parameter specifies the flag (.flg) file to use for processing flags in the scripts. You'll almost always want this to be "TESV_Papyrus_Flags.flg"

All[edit | edit source]

-all
-a

Compiles every single script in the specified folder. (The folder path replaces the filename as the first argument to the compiler) This is usually faster then compiling each script in the folder independently, as the compiler can re-use data.

Quiet[edit | edit source]

-quiet
-q

Forces the compiler to be silent, only printing out any errors encountered. Usually used with the All flag to reduce the amount of spam sent to the output.

Common Errors[edit | edit source]

Common errors emitted by the compiler are listed on another page

Disassembling scripts with PapyrusAssembler.exe[edit | edit source]

PapyrusAssembler must be in the same directory as your pas/pex files. This does NOT convert pex files to psc files, it converts them to a semi readable assembly-like syntax.

PapyrusAssembler.exe scriptWithoutExtenstion -D

Decompile all pex files in a directory[edit | edit source]

From cmd:

for /F "tokens=*" %F in ('dir /b *.pex') do PapyrusAssembler.exe %~nF -D -Q

From a batch file:

for /F "tokens=*" %%F in ('dir /b *.pex') do PapyrusAssembler.exe %%~nF -D -Q


Language: English  • français