User Tools

Site Tools


public_scripts:debugging

Debugging Scripts

The more you use scripts, the more you need to know about what is going on behind the scenes. This becomes most obvious when the game isn’t working as you expected it to. Dromed provides some commands to aid in the debugging of scripts. To view the debug information, you need to have a monolog enabled. The monolog is a text file that records messages from Dromed, the game, and some scripts.

Monolog

There are two ways to enable a monolog. You could tell Dromed to automatically open it at startup. Edit your dromed.cfg or user.cfg configuration file. (I prefer to use dromed.cfg for editor-only options.) Add this line to the file:

monolog ??mono.txt??

You can use any name for the file. The disadvantage with automatically opening the monolog is that the previous contents of the file will be erased each time you start Dromed. Instead, you can manually open the monolog every time you need it. After starting Dromed, type the command:

mlog ??mono.txt??

If you type mlog close, then the monolog is closed. Opening a monolog with a different name will close the previous file.

Trace Lines

With the monolog open, you can use Dromed’s built-in script debugging commands. These are called trace lines. A trace monitors the messages sent to a particular object. You create a trace with the trace_add command. The command takes four arguments, the object to monitor, the message to trace, the word ”spew”, then a trace line number. A trace line is a group of traces so you can toggle many traces on and off together. You can have up to 32 different trace lines. A line is toggled with the trace_line command. The ”spew” argument tells Dromed to write the message to the monolog. The word ”break” could also be used, but this is only useful for script programmers with a symbolic debugger installed.

Trace lines just tell you when an object receives a certain message. Many messages contain extra information that you may want to know about. Public Scripts includes a script for this purpose. Add the script Spy to any object and it’ll record every message that the object receives in the monolog, along with the extra information from the message.

public_scripts/debugging.txt · Last modified: 2010/11/22 19:06 (external edit)