Important Site Docs
Articles
Skyrim Papyrus Scripts
- Details
- Category: The Elder Scrolls 5: Skyrim Modding Guides
- Last Updated on Wednesday, 21 March 2012 01:58
- Written by Giskard
- Hits: 3725
Skyrim Papyrus Scripts
Introduction
Everything in Skyrim has a scripts attached to it, these are default scripts and if you try and find them, you will find nothing. The reason being the scripts are assigned automatically to types of objects. These default scripts do not actually exist on the object but as given to them when you run the game. When you write a script for an object, you add your pit of code to the default script by extending it.
Which is where the EXTENDS part of the script name comes in, it says your script is Extending the QUEST script or the Actor script or what ever script the item uses. If you give the wrong type of script after the Extends part you will get an error when trying to use commands in it because each script has a set of commands that work on its type of object. Commands for chairs for example would not work on Actors or Quests. So you have to get the part after the EXTENDS part of the name right.
Using Default Commands.
The other thing you will notice is a lot of commands have a word before them such as Debug, Game, Utility, these are scripts too, they are default scripts like the Actor Script or Quest Script and can be used either by doing something like this first in your script....
Import GAME
Import Debug
Or by using the command like this.
debug.messagebox"Hi I am message box"
The name that precedes the .messagebox part is the script name, more on this below.
Script Objects.
A script is just a list of commands to perform on the quest or object it is attached too, in Skyrim the type of object determines the type of script it gets and what commands work on it. You are going to have to learn this the hard way because its not very well explained anywhere. But the Wiki does have a page called "Script Objects" that lists every type of script the game recognises, most have names that allow you to guess what object gets that script. If you click on Actor Script for example you will see all the commands that work on Actors, Actors are your NPCs btw.
So lesson 1, to know what commands will work on quests, actors or what ever by checking the scripts for them first.
Quest Scripts.
Quests are best seen as giant buckets full of scripts, if you open up the quest window and add a topic with a line "hello" as dialogue, it will get a script assigned to that line the moment you enter anything in the Begin or End boxes, the script will appear in the Script window just to the right. If you do anything in Quest Stages, a script will appear under the Quest Windows Script tab at the very end of the other tabs. If you add your own script to a quest, you usually add it to the Script Tab too. All of these scripts will EXTEND Quest because they are all Quest scripts that use the default Quest script as a base.
The Player Dialogue Scripts for each line of dialogue typically control the Begin and End boxes for each line of spoke dialogue and usually what you enter in the begin and end boxes gets written to this quest a script automatically, right clicking and selecting edit source will show you the script.
The Quest Stage tab typically gets a script under the Quest Windows Script tab and controls quest stage tab. This too tends to be auto created and can be viewed by right clicking and selecting Edit source.
Your own scripts are added manually under the Quest Windows Script tab. Again right clicking and selecting edit source lets you view your script. But it is this script, the one you created that typically holds the properties and vars you want to share with other scripts and quests. So it is this one that you use the Property button on the most. More on that below.
How scripts talk to each other.
Scripts are either calling scripts that use another scripts functions and vars, or they are storage scripts that just hold functions and vars for other scripts to use or a little of both. Before a calling script can use any function from another script or even its own script, it has to add it as a property first pointing to the quest that has the var or function it wants to use.
Once a property exists declaring a var or function then the script that has this set on it, can use quests functions or vars. The script that just holds the function or var does not actually need to declare it for other scripts to use it, only the scripts that wish to use it, need to declare it.
So if we had script A wanting to ask Script B for an actors name using a special function. We would have to add a special property to Script Ato tell it to look in Script B for the answer. Script B would not need a property despite being the one with the information we need.
Adding and removing Properties from Scripts
If you select a script on a quest or anywhere else you will see a Properties tab exists somewhere. For example a Quest has a Script tab in the Quest window, if you click on it and see a quest script, select it and the Properties tab will become available. Click on that and you will see the properties already declared for that quest. Because the editor does not allow us to refer to our quest by its real name anymore, we must make a property to replace the name with a var in every script that needs to know a quests actual name.
So we click add property, select type quest, add short version of the quests name represent the quest and then okay it and wait for the new property to appear on the list. Then we select it and select edit value and point it at the quest we want it to represent. From now on we can refer to our quest by its short name anywhere in the script with this set as a property. If its a quest, any quest script in the quest can access it too.
How its accessed changes according to where that information is found.
If its from the current quest and not a other quest, we can do it like this.
(GetOwningQuest() as myquestscript).myVarOrFunctionName()
If its in another quest script entirely we must do it like this.
(Questshortname as myquestscript).myVarOrFunctionName()
The Questshortname is the short name you gave in the property and myquestscript is the name of your script as written at the top of a script before the word EXTENDS and the myVarOrFunctionName() is simply the var of function your trying to access. If it was a var you would probably do something else to it like.
Such as declaring a very short word to say "(GetOwningQuest() as myquestscript).myVarOrFunctionName()" and then doing all the fancy stuff you do on a var using the short name instead. Typically these can be put in functions that can be reused over and over again so its probably best to stick to using functions and let the function set the var.
If you find you need to remove something you added as a property you have to right click on the script and select Edit Source. Then you can edit out the property you do not want.
Making a Script that Extends one of your own scripts.
It is actually possible to Extend your own scripts instead of the default ones, to do it just right click in any script window and select Add Script, then select New Script from the popup box and type in your new script name next to Name and the name of the script you want it to extend next to Extends and okay it.
If you right click on the new script you will see it extends your old script but is completely empty besides that, but if you click on properties, you will see it shares all the properties your old script set up, meaning you do not need to declare them twice. I have yet to experiment with this but it seems like a pretty useful feature :)
Final thoughts.
Its not a simple case of learning the commands anymore, you have to learn what commands work on what type of object and how to access variables and functions from different scripts and quests and its not very well explained. Hopefully this guide will help you get over that initial problem but these are still early days for me too and I am making notes about what works as fast as I can and may get some things wrong. But I will be adding more tutorials and editing existing ones to include new information as I figure it out.
So check back often for updates.
Login Form
Forum and Website Logins
Please be aware that the forum and the main website are 2 completely different logins.
Skyrim Menu
Fallout New Vegas Menu
Fallout 3 Menu
Oblivion Menu
Game Guides
Misc Menu
Who is online
We have 47 guests and one member online





/ 3








