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 4. Flow Control}string msg;if(!attached){if((perm & PERMISSION_ATTACH) && (dist < 10.0)){attach();}else if((dist > 10.0) || ((dist > 20.0) && (balance > 1000))){move_closer();}else{llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);}}4.2. Loop ConstructsLoops are a basic building block of most useful programming languages, and LSL offers the the same loopcostructs as found in Java or C.4.2.1. for loopA for loop is most useful for when you know how many times you need to iterate over an operation. Just like aJava or C for loop, the parentheses have three parts, the initializer, the continuation condition, and the increment.The loop continues while the middle term evaluates to true, and the increment step is performed at the end ofevery loop.// move a non-physical block smootly upward (positive z) the the total// distance specified divided into steps discrete moves.move_up(float distance, integer steps){float step_distance = distance / (float)steps;vector offset = ;vector base_pos = llGetPos();integer i;for(i = 0; i

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

Saved successfully!

Ooh no, something went wrong!