Papyrus Compiler

Revision as of 13:07, 6 December 2018 by imported>Qazaaq (Scrivener07 moved page Papyrus Compiler Reference to Papyrus Compiler: Simply the tool name)

What is the compiler?

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

In the Creation Kit

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 a project with the equivalent of the following command line to build scripts (see below):

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

You can tell the Creation Kit to build in release or release final mode as well via the Creation Kit's preferences page. Release adds the "-r" and "-op" flags to the command, and release final uses the release flags plus the "-final" option.

Outside the Creation Kit

Power-users may want to execute the compiler via the command line, or via a batch file, or even through your favorite text editor. 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.

You may also pass a project if you specify the .ppj extension, for more information, check out the page on projects. Any command line arguments override any project settings.

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>"
-optimize
-release
-final
-all
-quiet

Import

-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 compiling a project, these specify places to look for the project, but the project's own import folders will override this when searching for scripts.

Files in folders listed first override ones in folders listed after.

Output

-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

-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 "Institute_Papyrus_Flags.flg"

Optimize

-optimize
-op

This parameter tells the compiler to perform basic optimizations on the script. You will usually want this on for any script you release.

Release

-release
-r

This parameter tells the compiler to remove all debugOnly function calls from the script, optimizing it and reducing its size slightly (depending on how many you use). You will usually want this on for any script you release.

Final

-final

This parameter tells the compiler to remove all betaOnly function calls from the script, optimizing it and reducing its size slightly (depending on how many you use). You will usually want this on for any script you release.

All

-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

-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

Common errors emitted by the compiler are listed on another page

See Also