! | When the "!" symbol is used, that means the statement is NOT true. |
if (!flag){
command(s); } |
Command(s) will be executed only if
"flag" is
not true.
Can be used with variables, as in the following example. |
if (!myvar==1){
myvar=1; } |
In this example, if myvar is not equal to 1, then set myvar to 1. (can also be written as: if (myvar!=1)) |
&& | Used as "and". All statements must be true in order for the commands to be executed. |
if (playertouchsme&&playeronhorse){
message Don't touch me with that horse!; } |
If the player is on a horse AND the player touched the NPC, the text "Don't touch me with that horse!" will be displayed. |
|| | Is used to signify OR. |
if (washit ||
wasshot){
message Ow!; } |
In this case, if the NPC was hit or shot, it'll say "Ow!". |
== | Denotes equals. Mainly used for variables and strings. |
if (myvar==5){
message It's 5.; } |
So of course this means if myvar is equal to, or "equals", 5, then display the message "It's 5.". |
= | Is used to assign a value. |
if (playertouchsme){
myvar=1; } |
This assigns myvar to 1 when the NPC is touched. Do not confuse assigning something, and checking to see if something is equal to something else, it'll mess up your scripts. |
+ | Is used for addition. |
if (myvar==0){
myvar=myvar+1; } |
In this case, if myvar is equal to 0, then add 1 to myvar. |
- | Is used for substraction. |
if (myvar==5){
myvar=myvar-2; } |
If myvar is equal to 5, then assign myvar to myvar minus 2 (thus 3). |
* | Means multiplication. |
if (myvar==3){
myvar=myvar*5; } |
Assigns myvar to myvar times 5 if myvar is equal to 3. |
/ | Denotes division. |
if (myvar=4){
myvar=myvar/2; } |
Of course if myvar=4, then I need to divide it by 2! |
% | This is used as a mod; Where a%b = a - int(a/b)*b, this would look like: |
if (myvar==8){
myvar2=myvar%5; } |
Basically it returns the value of the remainder of 'a' divided by 'b'. So myvar2 would be 3, since the remainder of 8 divided by 5 is 3. |
^ | Powers, or Exponents; ^0.5 = squareroot |
if (myvar==9){
myvar ^.5; } |
This would take the square root of myvar. |
a += b | Shorthand way to add. |
if (myvar==0){
myvar+=3; } |
Is the same as: |
if (myvar==0){
myvar=myvar+3; } |
Just a shorter way of doing things =) |
a -= b | Same as above but for subtracting. |
a *= b | Same as above but for multiplication. |
a /= b | Same as above but for division. |
a ++ | For the really lazy. |
if (myvar==0){
myvar++; } |
Which is the same as: |
if (myvar==0){
myvar=myvar+1; } |
The difference in this shorthand method as opposed to the other is, "++" is like adding 1 to the variable. The other method "+=number" allows you to add any amount. |
a -- | Same as above, but for subtraction. |
min(a,b) | Calculates the min of a,b |
max(a,b) | Calculates the max of a,b |
a in b | Used to check if the specified value is in the specified array. |
myvar=3; myarray = {1,2,3,4,5}; if (myvar in myarray){ message Yes.; }else{ message No.; } |
This checks to
see if the value of 'myvar' is also the value of one of the indexes of
'myarray'. Note that you can also do:
myvar in |1,5| to see if 'myvar' is greater than or equal to 1 and less than or equal to 5 or myvar in <1,5> to see if 'myvar' is greater than 1 and less than or equal to 5. |
random( a, b ) | Assigns a random number to a variable. Such as: myvar=random(1,5) This will set "myvar" to a random number between 1 and 5. It will not be a whole number. |
sin( a ) | The sine of an angle. This is in radians, NOT degrees, to convert from radians to degrees multiply by (180/3.14). |
cos( a ) | The cosine of an angle in radians. |
arctan( a ) | The arctan of an angle in radians. |
int( a ) | Rounds off the variable to the nearest whole number. |
abs( a ) | Finds the absolute value of a variable. |a| |
log(base,x) | what exponent the base must be powered to in order to reach x log(2,8) = 3 because 2^3= 8 |