Programming Errors
Before you can resolve any errors, you have to find out what is wrong with your code. Most importantly, make sure your cog
is running by putting a Print() statement in your cog.
If you have an 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 CogWriter 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 compile 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 a "random error." Almost all of the time, JK will crash because of a programming error.
Crashes during gameplay:
- The thing that the camera was focused on was removed from the game. 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.
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.
System 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. This probably can't be caused by cog. It will more likely happen when you try to do something
graphically intensive - such as trying to create many fine particle trails on a machine that does not have a graphics accelerator.
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.