-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

Move on Click

integer     g_Up;
 
default
{
    touch_start(integer total_number)
    {
        g_Up = !g_Up;
        vector pos = llGetPos();
        if(g_Up)
        {
            pos.z++;
        }
        else
        {
            pos.z--;
        }
        llSetPos(pos);
    }
}

Counter – Adds one by Touch

integer x = 0;
 
default
{
    state_entry()
    {
        llSay( 0, "x has a value of: " + (string)x );
    }
 
    touch_start(integer total_number)
    {
        {
            x = x + 1;
            llSetText((string)x,<1,1,1>,1);
        }
    }
}

Light Switch

integer switch = TRUE;
integer count = 0;
 
default
{
    state_entry()
    {
        llTriggerSound("091402dc-f0ea-81d4-6ca0-728649a1c0c5",0.0);
    }
 
on_rez(integer start_param)
    {
       llResetScript();
    }
 
    touch_start(integer total_number)
    {
        if (switch == FALSE)
        {
            switch = TRUE;
            llSetPrimitiveParams ([
            PRIM_POINT_LIGHT, TRUE, <1, 0.5, 0>, 1.0, 10.0, 0.00 ,
            PRIM_GLOW, ALL_SIDES, 1.0]);
            llTriggerSound("091402dc-f0ea-81d4-6ca0-728649a1c0c5",1.0);
        } 
 
        else if (switch == TRUE)
 
        {
            switch = FALSE;
            llSetPrimitiveParams ([
            PRIM_POINT_LIGHT, FALSE, <1, 1, 1>, 1.0, 10.0, 0.75 ,
            PRIM_GLOW, ALL_SIDES, 0.0]);
            llTriggerSound("091402dc-f0ea-81d4-6ca0-728649a1c0c5",1.0);
        }
    }
}

Teleport On Click

//  Teleport Sit Hack
//  Created by Water Rogers for IBM/Opensource
 
//  Purpose
//  --------------------------------------------------------------
//  This is a quick example of how you can make a teleporter type
//  object using the "Sit Hack".
 
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
 
//  Usage
//  --------------------------------------------------------------
//  We set up this object to "Sit on object when left clicked" making
//  it easier on the user.  Otherwise, you could right click and chose
//  "sit" from the pie menu.
 
//  GLOBALS
//  --------------------------------------------------------------
string      g_SitText   =  "Teleport";          //  This changes the text on the pie menue when rightclicked on the object
vector      g_SitOffset =  <0.0, 0.0, 10.0>;    //  This is the sit offset, also considered the teleport location from the object
 
//  EVENTS
//  --------------------------------------------------------------
default
{
    state_entry()
    {
        //  Set up the llSitTarget() and sit text first
        llSetSitText(g_SitText);
        llSitTarget(g_SitOffset, ZERO_ROTATION);
    }
 
    changed(integer change)
    {
        key id = llAvatarOnSitTarget();
        if(change & CHANGED_LINK)
        {
            //  We detect that the avatar sat on the object, so we
            //  unsit them right away thus giving the illusion of a
            //  teleport.
 
            //  Adjust the sleep time depending on the distance of
            //  the teleport.  The further the teleport, the higher
            //  the sleep value should be.  Note that the furtherst
            //  'teleport' distance is 300 meters.
            llSleep(1);
            llUnSit(id);
        }
    }
}

Squeeky Toy

default
{
    state_entry()
    {
       llSetText("Touch the squeekytoy!", <1,1,1>, 1.5);
    }
 
    touch_start(integer total_number)
    {
        llSay(0, "You touched it \o/!");
        llPlaySound("360bcb15-fc53-1e63-90c5-240df8fd2b19",1);
    }
}