Programming Errors


The most important debugging tool has to be the Print() command. If you have a cog that simply won't do anything ingame, try putting a Sleep() and Print() under the startup message to make sure the cog is running.

If you have a common error that is not in this list, send an email to the address on the main page so that this document can be updated.


Cog Doesn't Run

There are several things that could cause this symptom:

Crashes

A "crash," as it is used in this text, is the sudden termination of Jedi Knight. For a programming language, Cog (and JK in general) is amazingly crash-resistant. Syntax errors will stop a cog from running and not crash, you can leave variables undefined, mismatch symbol types, declare messages that don't exist, and make many other blunders that just wouldn't work in another language. And because of this, it is usually easy to fix a crash or freeze when it happens.

There are, however, special cases when JK will crash for no apparent reason. But even so, when JK crashes, do not assume that it was some random error. Almost all of the time, JK will crash because of a programming error.

Crashes during gameplay:

Crashes when loading JK: Crashes when loading a level:

Freezes

A freeze occurs when the game suddenly stops and your system does not respond. The only thing to do is reboot.

Engine Overload

This type of error occurs when you are taxing the JK engine. When this happens, JK will begin to skip over things. For example, projectiles will disappear. Among other things, this could be caused by trying to create too many fine particle trails.

Cog Runs Twice

Most likely, you will not know your cog has been loaded twice, but your cog will seem to defy all rules of programming.

Put a Print() statement after a short sleep in the startup message to see if your cog is being loaded twice. If the Print() statement prints the string to the screen twice, you will know the cog is being loaded twice. Check where your cog is listed and remove the duplicate entry.