Variables are basically place holders. Just like in algebra, variables are words/letters that store information. In the CoD scripting language there are four different types of variables.
Now, let's look at an example of these variables.
aString = "string"; anInterger = 12345; aFloat = 0.1234; aBool = true;
A string is basically a word, which must be put into quotation marks. Integers are whole numbers, floats are decimal numbers, and a boolean is a variable that only has two values; true or false.
Any of the above variables can be attatched to different entitys.
variable self.variable level.variable
The first or "private" variable can only be called within the thread or function it was created in. The self and level variables can be called from anywhere in the .gsc. The difference between self and level is that self is attatched to the player that created it and can only be modified by him, whereas level is attatched to everyone in the game and can be modified by anyone.
- Every variable must end with a semi colon unless it is being used in a loop or if statement.
- The string variable must be inside a pair of quotation marks.
- Integers, floats or booleans do not need to be inside quotes because they are numbers.
- Putting quotes around a variable that isn't a string will cause it to become a string, which in turn could cause you to mess up in the future.
- Variables must begin with a letter, contain no spaces or special characters.
These are different ways you can assign values to variables. They are really self explanatory and should be understood quite easily if you're familiar with algebra.
Binary Arithmetic Operators
|Addition||+||x + y||x plus y|
|Subtraction||-||x - y||x minus y|
|Multiplication||*||x * y||x multipied by y|
|Division||/||x / y||x divided by y|
|Modulus||%||x % y||Remainder of x divided by y|
Arithmetic Assignment Operators
|Assignment||=||x = y||x equals y|
|Addition Assignment||+=||x += y||Add y to x|
|Subtraction Assignment||-=||x -= y||Subtract y from x|
|Multiplication Assignment||*=||x *= y||Multiple x by y|
|Division Assignment||/=||x /= y||Divide x by y|
|Modulus Assignment||%=||x %= y||Add the remainder of x / y into x|