11.07.2015 Views

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3. Basics3.2. Arithmetic OperationsMost of the common arithmetic operations are supported in lsl, and follow the C/Java syntax.3.2.1. AssignmentThe most common arithmetic operation is assignment, denoted with the ’=’ sign. Loosely translated, it means,take what you find on the right hand side of the equal sign and assign it to the left hand side. Any expression thatevaluates to a basic type can be used as the right hand side of an assignment, but the left hand side must be anormal variable.All basic types support assignment ’=’, equality ’==’ and inequality ’!=’ operators.// variables to hold a information about the targetkey g_target;vector g_target_postion;float g_target_distance;// function that demonstrates assignmentset_globals(key target, vector pos){g_target = target;g_target_position = pos;}// assignment from the return value of a functionvector my_pos = llGetPos();g_target_distance = llVecDist(g_target_position, my_pos);3.2.2. Binary Arithmetic OperatorsBinary arithmetic operators behave like a funtion call that accepts two parameters of the same type, and thenreturn that type; however, the syntax is slightly different.Table 3-1. Binary Arithmetic OperatorsOperatorMeaning+ Addition- Subtraction* Multiplication6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!