Who Is Online

1
Online

Tuesday, 16 October 2018 03:34

If Else Example

// Bromley College
// Linden Script Exhibition
 
// Code for poster 16;
 
// You will notice that this program contains two states default and new. It was necessary to introduce states in this example in order to prevent the poster listening continuously and responding to all events on channel 0. Before introducing states the else condition was even "replying" to the chat messages produced when posters 17 and 18 were touched! ;
 
default
{
    touch_start(integer total_number)
    {
        llSay(0, "What is the number of this              poster? Please reply using chat.");
        state new;
    }
}
 
state new
{
    state_entry()
    {
       llListen(0,"",NULL_KEY, "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if(message=="16")
        {
            llSay(0,"Well done your answer is correct");
        }
        else
        {
        llWhisper(0,"Sorry wrong answer, please click on this poster to try again");
        }
        state default;
    }
}
 
// End of code;

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool