Getting the debug messages to print to the log or the screen can really help when trying to track down a problem in your module. Following up on some leads from jackyo123 and a few frustrating google searches, here's how I got it to work:
1. Set the Toolset to compile with Debugging
I'm not entirely sure this is needed or how this affects module, but it's also useful for using the ScriptDebuggerServer, so I have it on.
- Go to view > options
- Click on the script link
- Set GenerateDebugInformation to TRUE
2. Edit nwnplayer.ini
This one took me a while to find, partly because the documentation for DebugPostString() says you need to edit nwn.ini instead of nwnplayer.ini.
- Open nwnplayer.ini with notepad. Most people will find it at C:\Documents and Settings\Sean\My Documents\Neverwinter Nights 2\nwnplayer.ini
- Near the bottom of the file, under [Server Options], find the two lines that say "Scripts Print To Log=0" and "Scripts Print To Screen=0". Change these both of these values to "1" to get messages to print out to both the log and the screen. Change only one if you like.
3. Add PrettyDegug messages
Add your PrettyDebug messages where you want them. You'll notice that you'll get a lot of messages from the regular scripts, as well. These are great when you trying to figure out why the script that seems to be saying it should do something, isn't doing what you want.
4. Turn the Debug Messages On
You can do this in the game or you can do this via the ini file.
In game:
- Press the "`" (teldah) key to get to the console.
- Type "DebugMode 1"
- Type "debugtext"
- Press the "`" key again to return to the game.
In the nwnplayer.ini:
- Open C:\Documents and Settings\Sean\My Documents\Neverwinter Nights 2\nwnplayer.ini with notepad.
- Under[Game Options] add "Debug Text=1"
- Note that you can always override this in the game.
If you are sending debug information to your logs, they will appear at:
C:\Documents and Settings\Sean\Local Settings\Temp\NWN2\LOGS\nwclientLog1.txt
If you are sending debug information to the screen, they will appear up by the mini-map.
The logscriptrun command
Thanks to jackyo123 for pointing this out. If you type in "logscriptrun" in the console while in debug mode, your log will fill up with all the scripts that are being called. It can be a bit much to wade through, but sometimes it's good to see if something was run.