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:
- Syntax error. Check your cog with a syntax checker for this error.
- Listed incorrectly. Make sure your cog is correctly listed in a JKL or the items.dat.
- You loaded a saved game with different cogs.
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:
- Removing the thing that a camera is focused on. This error is most often caused
when a player is accidentally destroyed.
- Clearing the 0x4 or 0x8 Attach Flags from an attached object. Use DetachThing() to break an attachment.
- Improper use of ParseArg(). Some template settings cannot be modified with ParseArg().
- Trying to access an array variable that does not exist.
- Improper use of the Heap verbs.
- Improper change of a thing's collide setting.
Crashes when loading JK:
- Bad syntax in some sections of a JKL.
Crashes when loading a level:
- A bin flagged as an item or force power has no icon.
Freezes
A freeze occurs when the game suddenly stops and your system does not respond. The only thing to do is reboot.
- A cog may be running a loop indefinitely.
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.