Difference between revisions of "FAQ: My Script Doesn't Work!"
Jump to navigation
Jump to search
FAQ: My Script Doesn't Work! (edit)
Revision as of 13:56, 10 February 2012
, 13:56, 10 February 2012Consolidating this with new user-created Pitfalls page (overlap of intended use)
imported>JBurgess (Created page with "Category:PapyrusCategory:Solutions =Overview= Acclimating to Papyrus can be a difficult process - this page is here to help! The goal of this pa...") |
imported>JBurgess (Consolidating this with new user-created Pitfalls page (overlap of intended use)) |
||
Line 1: | Line 1: | ||
[[Category:Papyrus]][[Category:Solutions]] | [[Category:Papyrus]][[Category:Solutions]] | ||
=Overview= | =Overview= | ||
This is a page for the community to document common pitfalls, mistakes, and best practices when working with Papyrus. | |||
Acclimating to [[:Category:Papyrus|Papyrus]] can be a difficult process - this page is here to help! The goal of this page is to collect the most common stumbling blocks and hurdles we all encounter when trying to work with Papyrus scripts, especially early on. | Acclimating to [[:Category:Papyrus|Papyrus]] can be a difficult process - this page is here to help! The goal of this page is to collect the most common stumbling blocks and hurdles we all encounter when trying to work with Papyrus scripts, especially early on. | ||
Your contributions matter! If you've found a way around some sticking point, please add to this FAQ. | Your contributions matter! If you've found a way around some sticking point, please add to this FAQ. Links are strongly encouraged here as are code fragments to demonstrate what you're talking about. | ||
=FAQ= | =FAQ= | ||
==My Script compiles, but doesn't work! How can I debug this?== | ==My Script compiles, but doesn't work! How can I debug this?== | ||
When you begin working with Papyrus, you'll want to activate script logging. This feature is disabled by default - most users don't need it, and logging consumes a small amount of your PC performance in-game. | When you begin working with Papyrus, you'll want to activate script logging. This feature is disabled by default - most users don't need it, and logging consumes a small amount of your PC performance in-game. | ||
Line 48: | Line 51: | ||
Skyrim also includes [[:Category:Console_Commands|console commands]] that can help you track down what might be the problem. If your script is attached to a quest, type in “'''[[ShowQuestVars|sqv <quest>]]'''” 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 “'''[[PickRefByID|prid <reference id>]]'''” command) and then type in “'''[[ShowVars|sv]]'''” 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 “dpu” 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, “dps” will dump everything Papyrus is currently doing to the log for your analysis. | Skyrim also includes [[:Category:Console_Commands|console commands]] that can help you track down what might be the problem. If your script is attached to a quest, type in “'''[[ShowQuestVars|sqv <quest>]]'''” 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 “'''[[PickRefByID|prid <reference id>]]'''” command) and then type in “'''[[ShowVars|sv]]'''” 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 “dpu” 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, “dps” will dump everything Papyrus is currently doing to the log for your analysis. | ||
=== I Cannot create a new object === | |||
*Problem: I can't create a new object. | |||
*Explanation: Papyrus currently does not support the instantiation of objects within script; the '''new''' keyword only works for arrays, not objects (unlike Java, for example), and constructors do not seem to work. | |||
*Solution: For a workaround, you could try casting a PlaceAtMe ObjectReference as your desired object. Of course your object must extend ObjectReference for this to work. | |||
=== Can't cast an object as its child === | |||
*Problem: I can't cast an object as its child. For instance, casting an ObjectReference as a TestReference when TestReference extends ObjectReference. | |||
*Explanation: Casting will only work if the reference casted actually has its script attached. For instance, the TestReference base object needs to have the TestReference script attached in the editor form window for it to be castable from ObjectReference to TestReference. | |||
*Solution: Use the editor and attach the script to the object you're actually casting. For instance, if TestReference is supposed to refer to a book, open up the book you want to cast in the editor window, goto the scripts section, and attach the TestReference script from there. |