-->

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.

Give Object And Play Sound

// This script will give out a object from Inventory and play sound file when click on.
 
string object_name = "object";
integer i;
 
default
{
    state_entry()
    {
        llPreloadSound(llGetInventoryName(INVENTORY_SOUND, 0));
 
    }
     touch_start(integer total_number)
    {
         integer i;
        key giver;
        // add a wave that is name sound.wav
        llPlaySound("pour", 1.0);
        giver = llDetectedKey(0);
        string name = llDetectedName(0);
        if (giver != NULL_KEY)
        {
            llGiveInventory(giver, object_name);
        }
 }
}

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);
    }
}

Walking Sound

default
{
    state_entry()
    {
        llStopSound();
        llSetTimerEvent(0.001);
    }
 
    timer()
    {
        if (llGetAgentInfo(llGetOwner()) & AGENT_WALKING)
        {
            state walking;
        }
    }
}
state walking
{
    state_entry()
    {
        llLoopSound(llGetInventoryName(INVENTORY_SOUND,0),3);
    }
    timer()
    {
        if (!(llGetAgentInfo(llGetOwner()) & AGENT_WALKING))
        {
            state default;
        }
    }
}

Vomit

key target = "";
 
MakeParticles()
{
    if (target == "owner") target = llGetOwner();
    if (target == "self") target = llGetKey();
 
    llParticleSystem([
        PSYS_PART_FLAGS , 0
    //| PSYS_PART_BOUNCE_MASK
    //| PSYS_PART_WIND_MASK
    | PSYS_PART_INTERP_COLOR_MASK
    | PSYS_PART_INTERP_SCALE_MASK
    //| PSYS_PART_FOLLOW_SRC_MASK
    | PSYS_PART_FOLLOW_VELOCITY_MASK
    //| PSYS_PART_TARGET_POS_MASK
    | PSYS_PART_EMISSIVE_MASK
    //| PSYS_PART_TARGET_LINEAR_MASK
    ,
    //PSYS_SRC_TARGET_KEY,target,
    //Patterns:
    //PSYS_SRC_PATTERN_DROP
    //PSYS_SRC_PATTERN_EXPLODE
    //PSYS_SRC_PATTERN_ANGLE
    //PSYS_SRC_PATTERN_ANGLE_CONE
    //PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY     
 
    PSYS_SRC_PATTERN,          PSYS_SRC_PATTERN_ANGLE_CONE
 
    ,PSYS_SRC_TEXTURE,           "75f7ceed-1b02-6579-92e2-6464363139b3"
    ,PSYS_PART_MAX_AGE,          2.5
    ,PSYS_SRC_BURST_RATE,        0.01
    ,PSYS_SRC_BURST_PART_COUNT,  1
    ,PSYS_SRC_BURST_RADIUS,      0.01
    ,PSYS_SRC_BURST_SPEED_MIN,   .4
    ,PSYS_SRC_BURST_SPEED_MAX,   .6
    ,PSYS_SRC_ACCEL,             <0.0,0.0,-1.50>
    ,PSYS_PART_START_COLOR,      <.52,.02,.0>
    ,PSYS_PART_END_COLOR,        <.40,.10,.0>
    ,PSYS_PART_START_ALPHA,      1.0
    ,PSYS_PART_END_ALPHA,        0.0
    ,PSYS_PART_START_SCALE,      <.07,.07,.07>
    ,PSYS_PART_END_SCALE,        <.6,.6,.6>
    ,PSYS_SRC_ANGLE_BEGIN,       PI
    ,PSYS_SRC_ANGLE_END,         170 * DEG_TO_RAD
    ,PSYS_SRC_INNERANGLE,         PI
    ,PSYS_SRC_OUTERANGLE,         170 * DEG_TO_RAD
    ,PSYS_SRC_OMEGA,             <0.0,0.0,0.0>
            ]);
}
 
string ANIM = "express_open_mouth";
string ANIM2 = "express_anger";
vector pos;
 
default {
    state_entry()
    {
        llSetTimerEvent(0.0);
    }
 
    attach(key attached)
    {
        if (attached != NULL_KEY)
        {
            llRequestPermissions(attached, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
            llListen(23468723,"",NULL_KEY,"");
        } else
        {
            llSetTimerEvent(0.1);
        }
    }
 
    run_time_permissions(integer perms)
    {
        if(perms & (PERMISSION_TRIGGER_ANIMATION))
        {
            llTakeControls(CONTROL_LBUTTON,TRUE,TRUE);
        }
    }
 
    control(key id, integer level, integer edge)
    {
        pos = llGetAgentSize(id);
        float zee = pos.z;
        if(edge & level & CONTROL_LBUTTON)
        {
            llParticleSystem([]);
            llStartAnimation(ANIM);
            llStartAnimation(ANIM2);
            integer rand = llRound(llFrand(4));
            if(rand == 0)
                llTriggerSound("60edd6cd-6dd8-4520-d545-eca32e0ad7bc",1.0);
            if(rand == 1)
                llTriggerSound("efbda044-dc6c-c9f0-e622-1079c8c1a566",1.0);
            if(rand == 2)
                llTriggerSound("a7abc081-58b5-39c4-fd5e-8fc77362cfca",1.0);
            if(rand == 3)
                llTriggerSound("dd54d31d-9640-46e7-1cd1-33507182c2c5",1.0);
            if(rand == 4)
                llTriggerSound("36b4dc22-e5d0-4cb9-03c9-573bab173de3",1.0);
 
            MakeParticles();
            llSleep(1.25);
            llRezObject("puke",llGetPos() + <1.0,0,-zee/1.85> * llGetRot(),ZERO_VECTOR,ZERO_ROTATION,1);
            llParticleSystem([]);
        }
    }
    listen(integer channel, string name, key id, string msg)
    {
        pos = llGetAgentSize(llGetOwner());
        float zee = pos.z;
        list tokens = llParseString2List(msg, [" "],[]);
        if(llList2Key(tokens,0)==llGetOwner() && llList2String(tokens,1)=="drink")
        {
            llParticleSystem([]);
            llStartAnimation(ANIM);
            llStartAnimation(ANIM2);
            integer rand = llRound(llFrand(4));
            if(rand == 0)
                llTriggerSound("60edd6cd-6dd8-4520-d545-eca32e0ad7bc",1.0);
            if(rand == 1)
                llTriggerSound("efbda044-dc6c-c9f0-e622-1079c8c1a566",1.0);
            if(rand == 2)
                llTriggerSound("a7abc081-58b5-39c4-fd5e-8fc77362cfca",1.0);
            if(rand == 3)
                llTriggerSound("dd54d31d-9640-46e7-1cd1-33507182c2c5",1.0);
            if(rand == 4)
                llTriggerSound("36b4dc22-e5d0-4cb9-03c9-573bab173de3",1.0);MakeParticles();
            llSleep(1.25);
            llRezObject("puke",llGetPos() + <1.0,0,-zee/1.85> * llGetRot(),ZERO_VECTOR,ZERO_ROTATION,1);
            llParticleSystem([]);
        }
    }
}

Dialog Based Sounds Vendor

//Dialog Based sounds vendor by Kenny Jackson
 
//NOTES:
//1.) All sounds in the vendor will have the same price.
//2.) Set the price by changing the vendor description.
//(example. If you want the price of all the sounds in the vendor to be L$50 set the vendor description to 50.)
//3.) After adding new sounds to the vendor or changing the price or vendor name hit the RESET button to update the script. Only the owner will see the RESET button.
//4.) Just drop this script and the sounds your selling into a prim
//5.) Click the prim to get the dialog.
//6.) If your going to have more than 1 of these in a small area make sure to have a different channel number on each of them or all the vendors in the area will respond to the others dialogs.
//Kenny Jackson
 
integer price;
string wrong = "Sorry, that is not the correct price";
string over = "You have overpaid, here is your change";
string thank = "Thank you for your purchase";
integer finished = FALSE;
integer n = 0;
integer i;
list sounds;
integer CHANNEL = 123456;
string soundName;
string GNAME;
string Vname;
 
default
{
    state_entry()
    {
      while(!finished)
        {
            soundName = llGetInventoryName(INVENTORY_SOUND, n);
            if(soundName == "")
            {
                finished = TRUE;
                Vname = llGetObjectName();
                price = (integer)llGetObjectDesc();
 
                state debtperm;
            }
            else
            {
               sounds = sounds + soundName;
                n++;
            }
          }
        }
}
state debtperm
{
 state_entry()
    {
        //Do some initialization here
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    run_time_permissions(integer permissions)
    {
        //Only wait for payment if the owner agreed to pay out money
        if (permissions)
        {
            llSetText("Initailized Successfully...", <0,1,0>,1);
            state next;
        }
    }
}
state ready
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    state_entry()
    {
     GNAME = llList2String(sounds, i);
 
     llListen(CHANNEL, "",  "", "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if(channel == CHANNEL && message == "Reset")
        {
            llSetText("Resetting...", <1,0,0>, 1);
            llResetScript();
 
        }
 
        if(channel == CHANNEL && message == "Next")
        {
          i++;
 
          if(i >= n)
          {
          i = 0;
          state next;
 
          }
          else
          {
          state next;
          }
 
        }
        if(channel == CHANNEL && message == "Back")
        {
          i--;
 
          if(i < 0)
          {
          i = n - 1;
          state next;
 
          }
          else
          {
          state next;
          }
        }
        if(channel == CHANNEL && message == "Play")
        {
         llPlaySound(GNAME, 1);
         state next;
        }
 
    }
    touch_start(integer total_number)
    {
        if(llDetectedKey(0) == llGetOwner())
        {
        llDialog(llDetectedKey(0),"1.) Choose Next/Back to scroll through sounds.\n2.) Press Play to hear a sound.\n3.) Right Click and Pay to buy!", ["Back", "Next", "Play", "Reset"], CHANNEL);
         }
         else
         {
        llDialog(llDetectedKey(0),"1.) Choose Next/Back to scroll through sounds.\n2.) Press Play to hear a sound.\n3.) Right Click and Pay to buy!", ["Back", "Next", "Play"], CHANNEL);
         }
    }
 
    money(key id, integer amount)
    {
        if(amount < price)
        {
            llSay(0, wrong);
            llGiveMoney(id, amount);
        }
        if(amount > price)
        {
            llSay(0, over);
            llGiveMoney(id, amount - price);
            llGiveInventory(id, GNAME);
        }
        if(amount == price)
        {
            llSay(0, thank);
            llGiveInventory(id, GNAME);
        }
    }
}
state next
{
    state_entry()
    {
        GNAME = llList2String(sounds, i);
        llSetText(".:" + Vname + ":.\nClick for a dialog!\nSound Name: " + GNAME + "\nPrice: L$" + (string)price, <1,1,1>, 1);
        state ready;
    }
}