Skip to content

Papyrus: Getting Started

Alex Dunn edited this page Aug 13, 2014 · 7 revisions

From scratch, here's what it looks like to get running with compiling custom Papyrus scripts and using them in-game.

Initial Setup

There are many possible programming environments for Papyrus, including Notepad++. This is just one quick way to get start in case you aren't already set-up for Papyrus programming:

  1. Install Sublime Text (free)
  • Clone SublimePapyrus (You can click the Download ZIP button on the right-hand side)
  • Put the Papyrus folder into %AppData%\Sublime Text 2\Packages
  1. That's it! Just open any .psc Papyrus source file in Skyrim\Data\Scripts\Source. You can edit the text and then compile it with Control + B. Or, create new script and save it as a .psc into the same folder.
  • Even when a .psc file is present, Skyrim won't be able to use the script at runtime until you compile it.
  • By default, the Papyrus compiler won't find .psc files in subfolders. Put them directly into Skyrim\Data\Scripts\Source.
SKSE Plugins in Papyrus

Once you have a function in your SKSE plugin, you need to make it available to the Papyrus compiler. In the example project we have the function MyTest as a member function of MyPluginScript, so we need to make a papyrus script MyPluginScript.psc that looks like this:

Scriptname MyPluginScript   ; Declare the class you created in your SKSE plugin

Float Function MyTest() Global Native  ; Declare the function you created

Finally, compile the script to create MyPluginScript.pex. Native tells the compiler that it's handled by the executable instead of the script engine. In our case, the executable is our SKSE plugin. All .dll plugin functions will be Native, but they may not be Global.

You can find this example in the plugin_example project: plugin_example\scripts\MyPluginScript.psc.

You can compile the papyrus script and use it in other papyrus scripts without the dll being present (or even existing) and they will compile just fine since Native essentially tells the papyrus compiler to just trust that the functions exist and will work. Of course, if your dll isn't present or is not working, any script that calls your dll's functions will not work in game.

SKSE Plugin Compatibility

Many different people are making many different SKSE plugins, and users are going to have various plugins installed at the same time. To avoid conflicts between SKSE plugins, you need to make sure that all of your functions are defined in unique Papyrus classes. To start, you should never change any of the vanilla scripts. These should be changed only by the SKSE team.

For example, if you want to make a plugin that checks if a ReferenceAlias is a quest object (has the quest object box checked in CK) you might think to do add to ReferenceAlias.psc:

Bool Function IsQuestObject()

Instead, you need to make a new script file (Ex. "AlexReferenceAlias.psc") for your plugin and add:

Bool Function IsQuestObject(ReferenceAlias toTest)

Then you never have to worry about conflicting with another mod that has functions that work on ReferenceAlias or future SKSE updates since neither will change your script file.

More Help

This wiki is meant to focus on SKSE plugins and areas of Creation Kit and Papyrus that are poorly documented. Papyrus basics are pretty well documented, so it's best to read those tutorials to learn more about Papyrus scripting. As a start, I recommend these resources: