const
An unchanging value, usually an integer. Used in place of "magic numbers" to make code more readable.
Many constants have already been defined in the base game. For a list, see Category:Constants (they do not need the const keyword in nwscript.nss, this is always assumed).
Remarks
Only int, string, and float data types may be used as constants.
Constants must be defined in the global scope (i.e., outside of any function, void main(), or int StartingConditional()).
It's recommended that constants be in all caps, with underscores instead of spaces. This helps people reading your script to quickly tell which values are constants and which are variables.
As of 8193.36 const declarations can now contain any constant expression (such as arithmetic), including previously defined consts. So you can do const BASE_GOLD = 100; const GOLD_COST = 10 * BASE_GOLD;
for instance.
Example
const string MY_MESSAGE = "This string was defined in a constant!";
void main()
{
// Using a constant in code
SpeakString(MY_MESSAGE);
}