Having Papyrus trouble? Here are some things to try

Post » Sun May 05, 2013 11:37 am

So you’ve written an awesome script, got it all compiled, hop into the game excitedly to check out your work and… nothing happens. Or maybe you pull the Lever of Awesome and rocks fall on your head which, while funny, isn’t quite what you wanted to have happen. So how do you track down what might be going wrong with your script? This post will hopefully help to give you a good place to start, as well as pointing out various tools you can use to track down exactly what is wrong with your script.

One of the first things you will probably want to do is enable script logging. This is off by default in the game, but turning it on is a simple matter of changing just a few ini settings. The three ini settings you will be most interested in for debugging are http://www.creationkit.com/INI_Settings_(Papyrus)#bEnableLogging, which turns on and off the entire script logging system; http://www.creationkit.com/INI_Settings_(Papyrus)#bEnableTrace, which turns on the http://www.creationkit.com/Trace_-_Debug and related functions; and http://www.creationkit.com/INI_Settings_(Papyrus)#bLoadDebugInformation which will load in line number information so you can more easily pinpoint errors.

Once you’ve turned the settings on and launch the game, it should create a Logs folder inside “My Documents/My Games/Skyrim”. Inside that folder should be a “Script” folder. (If you don’t see the Script folder, you may need to launch the game a second time) Your logs will appear inside that folder, named Papyurs.#.log with the number going from 0 to 3. The 0 log is always the newest with older logs cycling through the increasing numbers.

The game should now be outputting some basic information, as well as any errors and trace statements to the 0 log while the game is running, so you should be able to keep an eye on it with your favorite text editor.

If the game detects an error in a script, it will output it in the following format:

 stack:   - "" Line    - "" Line    - "" Line   ...

Function 0 - the one at the “top” of the stack list - is the function that caused or reported the error. Function 1 is the function that called Function 0. Function 2 called Function 1, and so on. This will help you track down what might be the cause of any issues that are reported.

But maybe you don’t see any errors. What do you do then? Well, you can take advantage of various http://www.creationkit.com/Debug_Script functions, for example http://www.creationkit.com/Trace_-_Debug and http://www.creationkit.com/TraceStack_-_Debug, to help figure out what your script is doing, and what values your various variables or properties have. For an example, take a look at the following function:

Function MyFunction(int coolValue)  Debug.Trace("My function called! Coolvalue = "http://forums.bethsoft.com/topic/1345130-having-papyrus-trouble-here-are-some-things-to-try/+ coolValue)  If (coolValue == 20)	Debug.Trace("Cool value is 20! Doing some neat stuff now!")	; Do neat stuff!  EndIfEndFunction

Once you’ve added those trace statements to your function, you can now look at your log to try to pin down what is going wrong. Do you never see “My function called!” in the log? Then whatever is supposed to call your function isn’t happening, so you’ll have to keep looking. Do you see that line but you don’t see “Cool value is 20!”? Then you’ll have to figure out why the value isn’t what you wanted it to be. And you’ll note that in the example, we actually trace out the value of the variable by simply “concatenating” it with the “+” operator.

Skyrim also includes a few console commands that can help you track down what might be the problem. If your script is attached to a quest, type in http://www.creationkit.com/ShowQuestVars into the console to get a list of every Papyrus script attached to the quest, and the contents of all its variables and properties. If your script is attached to a reference, target the reference with your mouse while the console is up (or use the http://www.creationkit.com/PickRefByID command) and then type in http://www.creationkit.com/ShowVars to see the same amount of information, but for the reference. (PgUp and PgDown scroll the console output!) If your script is supposed to be registered for update events, type in http://www.creationkit.com/DumpPapyrusUpdates to have the game dump a list of every single updating form to the Papyrus log so you can see if your script is there. Or, if you think your script might actually be stuck inside an infinite while loop, or taking a while to respond, http://www.creationkit.com/DumpPapyrusStacks will dump everything Papyrus is currently doing to the log for your anolysis.

This only touches the surface of the tools and utilities available for helping to debug your scripts in the game, for more information please check out the http://www.creationkit.com/Category:Papyrus. In particular, the following pages may be quite useful:
  • http://www.creationkit.com/INI_Settings_(Papyrus)
  • http://www.creationkit.com/Papyrus_Compiler_Errors
  • http://www.creationkit.com/Papyrus_Runtime_Errors
  • http://www.creationkit.com/Console_Commands_%28Papyrus%29
  • http://www.creationkit.com/Debug_Script
As always, if you’re still stumped, ask for help on the forums! The people here are more than willing to help out a new or even seasoned scripter with some odd esoteric bug. And above all, have fun!
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Sun May 05, 2013 3:25 pm

These instructions have also been posted to anhttp://www.creationkit.com/FAQ:_My_Script_Doesn%27t_Work!. Help us improve the wiki by posting your own solutions to common problems encountered while learning Papyrus!
User avatar
Smokey
 
Posts: 3378
Joined: Mon May 07, 2007 11:35 pm

Post » Sun May 05, 2013 9:39 am

EditorIDs in Papyrus


There's one particular difference between Papyrus and the scripting language used for Oblivion and Fallout 3 that's giving a lot of people trouble. Even a fair number of experienced scripters have been tripped up by this.

In the old scripting language, it was possible to use some base form or persistent reference in a script just by using its editorID. However, if you try to do that in a Papyrus script you'll find that it won't compile. What you need to use instead is a http://www.creationkit.com/Variables_and_Properties#Declaring_Properties.

The way in which you'll almost always want to declare a property in Papyrus looks like this, using the type "http://www.creationkit.com/ObjectReference_Script" as an example:

ObjectReference property MyRef auto

Once you've declared a property like this, you then need to associate a value with it. In order to do this, navigate to the object with your script attached to it in the Creation Kit, right click on your script, and select "Edit Properties".

In this window, you can assign values to all of the properties in your script. You'll want to click on your property, and then click on the "Edit Value" button on the right hand side of the window. After you do this, a drop-down menu will appear in which you can select one of any form of the same type as the property you declared. So, for example, if you declared a property of type "http://www.creationkit.com/Ingredient_Script", the list would contain all ingredients currently loaded by the Creation Kit. In this example, the list will be filled with references.

As an added bonus, if the name of your property is the same as the editorID of the form that you want it to represent, then Creation Kit will be able to figure out what you mean. In this case, the "Auto-Fill" button will select that form automatically, so long as it's of the correct type. If you have a lot of properties like this, there's also an "Auto-Fill All" button at the bottom of the window.

Once you've done this, you'll be able to use your property as though it were the form you've associated with it.

P.S. I hope it's okay to post this here. I think this thread could have great value as a place to store answers to frequently asked questions about Papyrus.

A Bit More Technical


The reason why you can no longer use editorIDs directly in a script is that scripts are no longer included within data files. Instead, Papyrus source files (psc files) and compiled Papyrus scripts (pex files) are stored separately.

As a result of this, the Papyrus compiler does not look inside data files. Everything that links your Papyrus scripts with a data file must be done inside the Creation Kit. These actions include attaching a script to a form, and setting property values.

Cipscis

EDIT:

Just added a "Skyrim" section to cipscis.com, so now I'm hosting this little tutorial there as well - http://www.cipscis.com/skyrim/tutorials/editorids.aspx
User avatar
TRIsha FEnnesse
 
Posts: 3369
Joined: Sun Feb 04, 2007 5:59 am

Post » Sun May 05, 2013 12:10 pm

Hi there I had made an edit to the woodchoppers script, and even made a new one to make it that the woodchopper would do more than 3 goes per try, now I had only ever some how made it to do 1 and when i have manualy edited a file to make one work (eg making a PEX in script to load instead of the psc) it works but i cant bundle it with my other mod to upload onto workshop (im making a arrow smithing mod that edits the smith and the woodchopper)

I would like top know if im doing something wrong or if there is another way to upload the script with my mod.

Thank you for your time
User avatar
stevie critchley
 
Posts: 3404
Joined: Sat Oct 28, 2006 4:36 pm

Post » Sun May 05, 2013 11:38 am


There seems to be a problem with the way script replacements are handled when inside BSAs, see http://www.gamesas.com/topic/1345724-important-bsas-and-you/page__view__findpost__p__20290376 and also http://www.gamesas.com/topic/1345708-understanding-the-new-way-of-handling-scripts/.

The gist is: when the replacement scripts are present as loose files they work, if they are bundled in a BSA they only work if the BSA is registered in the ini. For your mod this means that you can either upload it to a site which allows loose files in the mods e.g. nexus or try to find a workaround, where you do not need to replace the original script.
User avatar
CHangohh BOyy
 
Posts: 3462
Joined: Mon Aug 20, 2007 12:12 pm

Post » Sun May 05, 2013 12:03 pm

that you, i will have to see what i can do, hope beth make a fix to this, maybe just allowing to set what items are included in your package and what important that have over the origanol content.
User avatar
Claire Vaux
 
Posts: 3485
Joined: Sun Aug 06, 2006 6:56 am

Post » Sun May 05, 2013 3:23 pm

I have heard somewhere that as of the latest official update, script replacements now work with no problems ...
User avatar
Big Homie
 
Posts: 3479
Joined: Sun Sep 16, 2007 3:31 pm

Post » Sun May 05, 2013 2:23 pm

This is technically a troll, but every time I enter the forums I see this topic and say this out loud to myself.

"Having Papyrus problems, I feel bad for you son, I got 99 problems but my scripts ain't one!"

but this topic is invaluable even for people who dont post to it, but read the comments already here
User avatar
Natasha Callaghan
 
Posts: 3523
Joined: Sat Dec 09, 2006 7:44 pm

Post » Sun May 05, 2013 4:45 am

I don't know if this affects anyone else, but I've picked up the habit, somewhere, of dropping empty brackets - and then I wonder why my script won't work until I get a wee hint from the compiler.
.
Spoiler

.
It looks good, but it doesn't compile because functions in the first few lines with default parameters are still lacking empty brackets (denoting something other than what is intended). If instead:
.
Spoiler

.
... we give the functions their empty brackets, the function compiles and, assuming no other problems, works as expected.
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Sun May 05, 2013 6:09 am

You'll always need the parenthesis for functions/events, even if not passing or using any arguments. The only instances I can think of that don't require the parenthesis are the Length http://www.creationkit.com/As and the Value property for GlobalVariable.
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm

Post » Sun May 05, 2013 10:57 am

Hmm gonna put this here..

Example

Event OnEffectStart(Actor akTarget, Actor akCaster)
is the correct parameter order.

Event OnEffectStart(Actor akCaster, Actor akTarget)
is the incorrect parameter order and will cause the event to fire on the caster only, despite any declarations made to akTarget.

So if you are having issues with a script and suspect that it is returning the player.. check the order of your parameters. Funny I thought this did not matter, but I found out the hard way.

Basically, the default parameter orders of all Events or functions, you should stick with.
User avatar
April
 
Posts: 3479
Joined: Tue Jun 20, 2006 1:33 am


Return to V - Skyrim