Instant Message Example

Expired

// Bromley College
// Linden Script Exhibition
 
// Code for poster 37
 
default
{
    touch_start(integer num_detected)
    {
            llInstantMessage(llDetectedKey(0), llDetectedName(0) + " touched me.");
 
            llLoadURL(llDetectedKey(0), "SL Home", "http://secondlife.com/");
    }
}
 
// End of code;

 

If Else Example

Expired

// 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;

 

While Example

Expired

// Bromley College
// Linden Script Exhibition
 
// Code for poster 18;
 
default
{
    state_entry()
    {
        llSay(0, "Compile Successful!");
    }
 
    touch_start(integer total_number)
    {
        integer  count = 1;
        integer  maxcount = 3;
        while (count 

 

States Example

Expired

// Bromley College
// Linden Script Exhibition
 
// Code for poster 19
// Colour vectors are set up as follows  where red green and blue can be anything from 0 (dark) to 1 (full bright). e.g. <1,0,0 > will be bright red, whereas <0.5, 0.5, 0 > will be medium yellow.
 
default
{
    state_entry()
    {
        vector prim_color = <1,1,1 >;
        llSetColor( prim_color, ALL_SIDES          );
    }    
 
    touch_start(integer total_number)
    {
        llSay(0, "Green State");
        vector prim_color = <0,0.75,0 >;
        llSetColor( prim_color, ALL_SIDES );                      //set colour to mid green
        state amber; //switch to the new state
    }
}
 
state amber
{
    touch_start(integer total_number)
    {
        llSay(0, "Amber State");
        vector prim_color = <1,0.75,0 >;
        llSetColor( prim_color, ALL_SIDES          );
        state red;
    }
}
 
state red
{
    touch_start(integer total_number)
    {
        llSay(0, "Red State");
        vector prim_color = <1,0,0 >;
        llSetColor( prim_color, ALL_SIDES          );
        state white;
    }
}
 
state white
{
    touch_start(integer total_number)
    {
        llSay(0, "White State");
        state default;
    }
}
 
// End of code;