Difference between revisions of "Debug Scripts"
grammar and minor corrections
imported>AdiBeiElderScrolls |
imported>Scruggs (grammar and minor corrections) |
||
|
The debug process with CS is quite time consuming and the provided tools are not really satisfying.
So here are some hints
===[[Script Processing]]===
First of all, you should take a look at the [[Script Processing]] article
Remember
Object scripts may run every frame, but they also may not execute for quite a while
To find out
<pre>; use long, if you want to watch the frames
===Control variable content===
There are different ways
The most convenient and reliable way is using the [[:Category:Console Functions|Console Functions]], especially '''prid''' and '''tst''' or '''sv'''. You always will get the real current content.
So, first activate or focus the object
If the object you want to examine cannot be left-clicked (because it's in a different cell, or disabled), you can select with the '''prid''' command if you know its form ID. The '''prid''' command will change to any object given, so if you want to examine your NPC script and your NPC has shown a '''formID''' of 0b002089 you simply enter:
<pre>prid 0b002089</pre>
<pre>sv</pre>
If you use many variables, you may only see the last ones. In this case,
To get a special variable content, use the '''Show/tst''' command. So if you want to control how much times the script has executed until now, if you have set a FrameRuns variable, you just type:
<pre>show FrameRuns</pre>
If that variable is not getting bigger and bigger everytime you leave the console and enter it again, you may just have the case
To see all of the variables within a particular quest, use '''ShowQuestVariables''' (or '''sqv''' for short):
'''Take care''', if you use [[Message]] or [[MessageBox]] functions inside of your script!▼
<pre>sqv QuestID</pre>
[[Message]] can be useful for showing which segment of code is executing, or the value of a variable at a particular moment, but because messages always stay on the screen for one second, consecutive messages will be delayed. This means the value of a variable displayed in a message may have changed before the message gets displayed. OBSE's [[PrintToConsole]] function can make debug messages easier to use.
[[MessageBox]] behaves in another way. If you want to have different message boxes, that pop up to show some variable content, you may end up with having only the last defined message box shown and all other ignored. ''Don't ask me why, but it seems to work this way''▼
▲[[MessageBox]] behaves in another way. If you want to have different message boxes
At least [[MessageBox]] gives you the current values in the script.
===Find bugs not reported by CS or Oblivion===
CS usually gives you some hints
You still can make syntax errors
Unfortunately, Oblivion does not provide any error messages within the game itself. If it encounters an error within a script, it will immediately terminate that script without notifying you. That's why it's useful to have a variable in your script that increments every frame - by checking that variable in the console, you can determine if your script has stalled.
Here's an example: It took me a whole day to find out
So the statement
</pre>
But the script saved without any problems and ingame I didn't get a message
<pre>disable objectID 1
PickIdle My name is Bob</pre>
[[Category:Scripting]]
| |||