Mod:Creation Kit/Papyrus Compiler

The Mod:Creation Kit/Papyrus Compiler is a command line utility used to compile Mod:Creation Kit/Script Files. The program will take source  files and convert them into executable   files, a format that Fallout 4 can understand. 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. The Mod:Creation Kit/Creation Kit uses this utility to compile scripts inside the editor as well. This utility is included with the Mod:Creation Kit/Creation Kit and can be found.

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

The Mod:Creation Kit/Creation Kit uses a project with the equivalent of the following command line to build scripts (see below): PapyrusCompiler -i=" " -o="Data\Scripts" -f="Institute_Papyrus_Flags.flg"

You can tell the Mod:Creation Kit/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 Mod:Creation Kit/Papyrus Project if you specify the  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=" " -output=" " -flags=" " -optimize -release -final -all -quiet

Import
-import=" ; ; " -i=" ; "

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=" " -o=" "

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=" " -f=" "

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