About this mod
PaperScript is a modern scripting language that compiles into Papyrus and is generally more modern and comfortable than Papyrus.
- Permissions and credits
- Mirrors
- Donations
You can follow me on Bluesky for real-time updates. You can also send me feedback there.
PaperScript is a modern alternative to Papyrus that transpiles into valid Papyrus code.
Source Code and Documentation
Why PaperScript?
Because Papyrus is annoying. It's not the worst language out there, but it's missing a lot of quality-of-life features and tends to be overly verbose.
For example, Papyrus doesn't support foreach or even for loops—just while. So something as simple as iterating over an array is tedious:
; Papyrus "foreach"
Int[] numbers = new Int[10]
Int numberIndex = 0
While numberIndex < numbers.Length
Int number = numbers[numberIndex]
DoSomething(number)
numberIndex += 1
EndWhile
With PaperScript, you can write:
numbers: Int[] = new Int[10]
range number in numbers {
DoSomething(number)
}
PaperScript transpiles that into the while loop for you—clean, readable, and less error-prone. More quality of life features, such as a switch are coming...
What Makes It Easy to Use?
From day one, PaperScript was designed to stay out of your way.
The transpiler doesn't just convert PaperScript to Papyrus—it also compiles it for you. When running in Project Mode, you configure the paths to your game's script source directory and the Papyrus compiler just once. After that, PaperScript takes care of the rest.
Whenever you update a .pps file, PaperScript automatically:
- Transpiles it to Papyrus (.psc)
- Copies it to your game’s script source folder
- Runs the Papyrus compiler to produce the final .pex file
This means you can keep your PaperScript sources in a clean, organized Git repo—anywhere you like. PaperScript handles deployment and compilation behind the scenes, so you can focus on writing code instead of managing build steps.
In fact, it’s more convenient than writing Papyrus directly.
How It Works
The transpiler is built using C# and ANTLR4. This setup is great for rapid prototyping and early development, but the current version behaves more like a "Google Translate for code" than a full compiler.
This makes some features harder to implement and error reporting less helpful. For example, a simple typo like autso instead of auto might result in a confusing error:
syntax error at line 1, column 0: mismatched input 'property' expecting ':
In v2, the plan is to implement a proper recursive descent parser that builds an AST (Abstract Syntax Tree) and generates Papyrus from that. It'll be more robust, easier to extend, and allow for better error messages.
How to Use It
There are two main modes: single file and project.
🗃️ Project Mode (recommended)
Create a project.yaml file by running:
paperscript.exe init
Then compile all scripts in a folder by running:
paperscript.exe build
The project.yaml file contains paths to your skyrim script folder path. If you run init as admin, it will configure it automatically.
📄 Single File Mode
Transpile one .pps file at a time:
paperscript.exe transpile [file_name]
For syntax reference and more detailed documentation, please see the GitHub repo.