This is a tip for advanced Windows users. I will be assuming you're familiar with the command line, environment variables, and batch scripts.
Steps
- Create a folder named Scripts wherever you want.
- Add that folder to your PATH environment variable. (System Properties > Environment Variables...)
- Copy the Papyrus Compiler folder from the game directory to that folder.
- IMPORTANT: If you ever have to reinstall Skyrim, you don't want to lose your ability to compile, which you will if you use a modified ScriptCompile.bat in the Papyrus Compiler folder, so moving the compiler out of the Skyrim directory is a good practice. Fortunately, you'll never use ScriptCompile.bat again, but if you ever want to compile scripts without Skyrim installed, you'll still benefit.
- Create a new file in that folder named compile.bat.
- Edit that file in a text editor and enter the text under the respective heading below. Change the paths to fit your needs.
- Note the order of the -i[nput] paths. The order is very important, if you want to successfully compile SKSE and MCM scripts without dependency errors. This is NOT where you enter the path to your mod's /scripts/source/ folder.
- Save the file when you're done and close the text editor.
- Open a new command prompt and go to your mod's /scripts/source/ folder. Note: Changes to the PATH environment variable through System Properties take effect only in new command prompts, not existing sessions, so ensure that you open a new command prompt if you had one open before.
- Type "compile" and press Enter. After the script finishes execution, press Enter to get the command prompt to show again. Also be aware that the batch script, as written, will dump all of your compiled scripts into the parent folder, meaning that if you compile in the /scripts/source/ folder, all of the *.pex files will save to the /scripts/ folder. That makes development and testing easier, in my opinion, but you may want to change this behavior, in which case you can simply alter the -o[utput] parameter to reflect the path to the folder where you want your compiled scripts to be saved.
compile.bat
@echo offFOR /F %%i IN ('dir /a-d /b *.psc') DO (start /b cmd /k ""C:\Scripts\Papyrus Compiler\PapyrusCompiler.exe" %%i -f="C:\Scripts\TESV_Papyrus_Flags.flg" -i="C:\Games\Papyrus\SkyUI\scripts\source;C:\Games\Papyrus\SKSE\scripts\Source;C:\Games\Papyrus\USKP\scripts\source;C:\Games\Papyrus\Core\scripts\source" -o=".." -op && exit")
Example Input/Output
C:\Master of Disguise\scripts\source>compileC:\Master of Disguise\scripts\source>Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Starting 1 compile threads for 1 files...Compiling "dubhApplyingEffectScript"...Compiling "dubhDisguiseMCMHelper"...Compiling "dubhDisguiseQuestScript"...Compiling "dubhDisguiseMCMStringUtil"...Compiling "dubhPlayerScript"...Compiling "dubhFactionEnemyScript"...Compiling "dubhMonitorEffectScript"...Compiling "dubhDisguiseMCMQuestScript"...Starting assembly of dubhDisguiseMCMStringUtil0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhApplyingEffectScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhDisguiseQuestScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhMonitorEffectScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhDisguiseMCMHelper0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhPlayerScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhFactionEnemyScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.Starting assembly of dubhDisguiseMCMQuestScript0 error(s), 0 warning(s)Assembly succeededCompilation succeeded.Batch compile of 1 files finished. 1 succeeded, 0 failed.
That's how you make the Papyrus Compiler multithreaded!
In the future, you'll only need to type "compile" at the command line in the /scripts/source/ folder of your mod or any mod.
If you know how, you could also http://superuser.com/questions/444726/windows-how-to-add-batch-script-action-to-right-click-menu so you can run the script through Windows Explorer.
What's the benefit to compiling everything at once?
- One, all of your compiled scripts will have the same or similar timestamps, so that's cool.
- Two, you won't have to compile each file individually.
- More importantly, you'll never ask yourself, "Did I compile that script I changed?" Well, you still will, but now you have a solution.
Inevitably, someone will point out that you can use Notepad++ to compile albeit with a plugin. If you're happy with your current solution, good for you.
For me, especially for projects with multiple scripts, this is a much faster and more convenient way to compile scripts.