About this mod
Compile and deploy your papyrus scripts in two short words!
Basic command line application for compiling (.psc) / decompiling Papyrus (.pex) files
- Permissions and credits
Basic command line application for compiling (.psc) / decompiling Papyrus (.pex) files
Source Available Here (C#): https://gist.github.com/fromanan/7a05da7b153d0b99dd8307f623cd0375
This is a simplified wrapper for the Caprica and Champollion projects by @Orvid on GitHub
- Caprica: https://github.com/Orvid/Caprica
- Champollion: https://github.com/Orvid/Champollion
All credit for the Compiler/Decompiler to Orvid and the Caprica / Champollion teams, this is distributed as is and without modification. If you feel more comfortable downloading their binaries directly, click the GitHub links above and go to releases. Before running any free software online, I recommend running it through VirusTotal.com, a free website that cross-checks any uploaded files against several independent virus definitions.
This is the first tool being developed as part of my Birch Platform for Papyrus Development in C#, the full source code will be available when this releases later this year or early next year under MIT license (free, open-source, use/modify how you want with attribution)
Happy Modding! :)
Setup ///
Compiling
In order to compile, you must first decompile from source at least once. This requires that you use the Bethesda Archive Extractor (B.A.E) tool and extract the .ba2 files found in your "${GAMEROOT}\Data" folder.
Extract these to a folder you will remember: you will pass the scripts SUBFOLDER as the "--source" flag when you run the Decompiler.
After decompiling the .pex files produced from the B.A.E. using the step below, you should be able to compile your scripts as normal.
Decompiling
Extract the .pex files using B.A.E. as described above.
For decompiling, all you will need to do is pass the folder from step one as the "source" argument to the PapyrusAPI.exe. If you have not previously run PapyrusAPI (version >= 1.2), you will need to put the --game argument as well.
By default, this will extract to the path specified at the ${BASE} variable. You may override this by passing in the "--destination" argument
Usage ///
Parameters
Parameters are specified using the style of -{char}:{value} for a single character or --{word}:{value} for a full word
For compiling, you may either specify a script name either with -n / --name or just passing a flagless argument OR specify the scripts root folder (-r / --root) and the script name with extension (-s / --script)
The simplest setup would be to have all exe's in the same folder and for example, call
.\PapyrusAPI ShipUtils
This is equivalent to:
.\PapyrusAPI.exe
--script:ShipUtils.psc
--mode:compile
--deploy:true
--exe:".\Caprica.exe"
--root:${GAMEROOT}\Data\scripts\Source\User\ShipUtils
--game:"${GAMEROOT}\Data\Scripts\Source\Base"
--location:"${GAMEROOT}\Data\Scripts\Source\Base"
There are 6 special variables (case insensitive) you may use for paths to shorten them. If you specify the "game" flag or it is set in preferences, the root will reflect that instead of the value at ${GAMEROOT} and any values below it
They are:
${GAMEROOT} : C:\Program Files (x86)\Steam\steamapps\common\Starfield
${SCRIPTS} : C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts
${USER} : C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts\Source\User
${BASE} : C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts\Source\Base
${DOCUMENTS} : C:\Users\{username}\Documents
${MYGAMES} : C:\Users\{username}\Documents\My Games\Starfield
NOTE: If your game is not installed in the standard location, you will have to specify it with the "game" flag the first time you run PapyrusAPI. After this, it will be saved to your preferences and not needed for future runs.
Game Root
Optional (required if not installed via Steam on C:// drive FOR FIRST RUN, default value shown below)
- -g
- --game:"C:\Program Files (x86)\Steam\steamapps\common\Starfield"
- --gameroot:"C:\Program Files (x86)\Steam\steamapps\common\Starfield"
This will ALWAYS need to come before any arguments that use the ${GAMEROOT}, ${SCRIPTS}, ${USER}, or ${BASE} variables for them to work properly. If you have this value stored in preferences, you do not need to worry about this.
Run Mode
Default : Compile
- -m
- --mode:c
- --mode:compile
- --mode:d
- --mode:decompile
Script Name
Optional (default argument when no flags used)
- -n
- --name:"ShipUtils"
Script Root
Required (Compile -- when 'name' not set)
- -r
- --root:"C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\scripts\Source\User\ShipUtils"
Script
Required (Compile -- when 'name' not set)
- -s
- --script:"ShipUtils.psc" (mode=compile)
- --source:"C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\scripts\ShipUtils.pex" (mode=decompile)
Deploy
Optional
- -d
- --deploy:true
- --deploy:false
- --deploy:1
- --deploy:0
Executable Path
Optional (Default will assume it is in the same folder as the application)
- -x
- --exe:".\Champollion.exe"
Deploy Location / Decompile Destination
Optional (Default values shown below)
- -l
- --location:"C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts" (Compiling : Deploy Location)
- --location:"C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts\Source\Base" (Decompiling)
- --destination:"C:\Program Files (x86)\Steam\steamapps\common\Starfield\Data\Scripts\Source\Base" (Decompiling)
Clear Preferences
- -c
- --clear