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 15:24, 10 February 2012
, 15:24, 10 February 2012no edit summary
imported>JBurgess m |
imported>Jimhsu |
||
Line 9: | Line 9: | ||
=FAQ= | =FAQ= | ||
==My Script compiles, but doesn't work! How can I debug this?== | ==General== | ||
===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 52: | Line 54: | ||
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 == | ==Object Creation | ||
=== I Cannot create a new object === | |||
*Problem: I can't 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. | *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. | *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 == | === 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. | *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. | *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. | *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. |