Notes on Print Verbs


Concatenation

To Concatenate is to link together. In Cog, concatenation refers to linking values together into a string that is printed with jkStringOutput(). When you concatenate a value, JK adds it to the end of a stored string. jkStringClear() clears the stored string for a new series of concatenations. Each computer has its own concatenated string.

Here's an example of concat verbs in use:

jkStringClear();
jkStringConcatAsciiString("The number of players in this game is: ");
jkStringConcatInt(GetNumPlayers());
jkStringOutput(-3, -1);
Notice in that example that jkStringClear() is run before the concatenation. Even after the string has been outputted, it is still in memory. But because all concatenation code in cog clears the string before the concatenation, this will not cause problems.

Strings

A string, in programming terms, is a collection of letters, numbers, and odd characters which is enclosed by double quotation marks. There is no string symbol type to store a string with, but JK does store one string for concatenation. Uni files store generic strings. The two uni files that can be accessed by cog are jkstrings.uni and cogstrings.uni.

The jkstrings.uni holds strings that will be used during normal gameplay in any level. Strings like "Using Bacta" and "Fists" are stored in this file. Cogstrings.uni is a level file that holds the strings that are to be used by an episode. "Locked!" and "This looks interesting!" come from the cogstrings of The Force Within.

In both of these files, strings are defined like this: "COG_x" 0 "string" - where x is the number of the string. It is this number that cog verbs use to locate the string. If you give a verb the number to a string that does not exist, you'll see "COG_yourNum" print on the screen.

Destinations

Output Destinations
DestinationPlayer that receives the message:
0, 1, 2, etc.If there's a player with the thingref of this dest, the message is sent to him. Otherwise, it's local.
-1Local player.
-2Unknown.
-3Everyone.

Debugging

The print verbs are the most useful tools for debugging. Print() will tell you if a message runs and PrintFlex() will print the value of a variable. When you have a problem with a cog, one of the first things you should do is print something. The print verbs (and not the concat verbs) were most likely created just for debugging purposes.