Linden Scripting Language Guide - Engineering Center
Linden Scripting Language Guide - Engineering Center
Linden Scripting Language Guide - Engineering Center
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 4. Flow Controlbut the most basic scripts will require some kind of flow contol. LSL comes with a complete complement ofconstructs meant to deal with conditional processing, looping, as well as simply jumping to a different point inthe script.4.1. Conditional StatementsThe ’if’ statement operates and has the same syntax as the Java/C version.check_message(string message){if(message == "open"){open();}else if(message == "close"){close();}else{llSay(0, "Unknown command: " + message);}}The statements between the open and close curly brace are performed if the conditional inside the parenthesesevaluates to a non-zero integer. Once a conditional is determined to be true (non-zero), no further processing of’else’ conditionals will be considered. The NULL_KEY constant is counted as FALSE by conditionalexpressions.There can be zero or more ’else if’ statements, and an optional final ’else’ to handle the case when none of the ifstatements evaluate to a non-zero integer.The usual set of integer arithmetic and comparison operators are available.// a function that accepts some information about its environment and// determines the the ’best’ next step. This kind of code might be// part of a simple box meant to move close to an agent and attach to// them once near. This code sample relies on the standard linden// library functions as well as two other methods not defined here.assess_next_step(integer perm, integer attached, integer balance, float dist){12