Difference between revisions of "LSL Operators"
Jump to navigation
Jump to search
Kris Kovacs (talk | contribs) m (fixed some errors in the bit manipulation examples) |
|||
Line 29: | Line 29: | ||
| == != || Comparison Equal, Comparison Not Equal || isFalse = ("this" == "that"); | | == != || Comparison Equal, Comparison Not Equal || isFalse = ("this" == "that"); | ||
|- | |- | ||
| & || Bitwise AND || zero = 4 & | | & || Bitwise AND || zero = 4 & 2; | ||
four = 4 & 4; | four = 4 & 4; | ||
|- | |- | ||
Line 35: | Line 35: | ||
six = 4 ^ 2; | six = 4 ^ 2; | ||
|- | |- | ||
| <nowiki>|</nowiki> || Bitwise OR || four = 4 | 4; | | <nowiki>|</nowiki> || Bitwise OR || four = 4 <nowiki>|</nowiki> 4; | ||
six = 4 | 2; | six = 4 <nowiki>|</nowiki> 2; | ||
|- | |- | ||
| && ||Comparison AND || isFalse = (FALSE && TRUE); | | && ||Comparison AND || isFalse = (FALSE && TRUE); |
Revision as of 10:32, 3 April 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Operators are used to cause an operation (or mathematical action) to be performed on two operands. The easy and common example is 1 + 2 where 1 and 2 are operands, and the + is the operator.
This concept can be extended much further with LSL since operands can be variables with the special case of the assignment operators requiring that the left hand side be a variable.
Operator | Description | Usage Example |
---|---|---|
() [] . | Parenthesis, Brackets, and Dot | do this second (do this first) |
(type) | Typecasting | message = "The result is:" + (string) result; |
! ~ ++ -- | NOT, One's Complement, Increment, Decrement | counter++; |
* / % | Multiply, Divide, Modulus | rollover = (count + 1)%5; |
- | Subtraction | one = 3 - 2; |
+ | Addition or joining Strings | two = 1+1;
text = "Hello" + "World"; |
<< >> | Left Shift, Right Shift | eight = 4 << 1; |
< <= > >= | Less Than, Less Than Or Equal To,
Greater Than, Greater Than or Equal To |
isFalse = (6 <= 4); |
== != | Comparison Equal, Comparison Not Equal | isFalse = ("this" == "that"); |
& | Bitwise AND | zero = 4 & 2;
four = 4 & 4; |
^ | Bitwise XOR | zero = 4 ^ 4;
six = 4 ^ 2; |
| | Bitwise OR | four = 4 | 4;
six = 4 | 2; |
&& | Comparison AND | isFalse = (FALSE && TRUE); |
|| | Comparison OR | isTrue = (FALSE || TRUE); |
= += -= *= /= %= | Assignment | four = 4; |