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

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 Control4.2.2. do-while loopThe do-while loop construct is most useful when you are sure that you want to perform an operation at leastonce, but you are not sure how many times you want to loop. The syntax is the same as you would find in a Javaor C program. A simple english transation would be ’do the code inside the curly braces and continue doing it ifthe statement after the while is true.// output the name of all inventory items attached to this objecttalk_about_inventory(integer type){string name;integer i = 0;integer continue = TRUE;do{name = llGetInventoryName(type, i);if(llStringLength(name) > 0){llSay(0, "Inventory " + (string)i + ": " + name);}else{llSay(0, "No more inventory items");continue = FALSE;}} while(continue);}4.2.3. while loopThe while loop behaves similarly to the do-while loop, excpet it allows you to exit the loop without doing asingle iteration inside.mention_inventory_type(integer type){integer i = llGetInventoryNumber(type);while(i--){llSay(0, "item: " + llGetInventory(i));}}14

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

Saved successfully!

Ooh no, something went wrong!