OsLoopSound

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Change See Also)
 
(6 intermediate revisions by one user not shown)
Line 4: Line 4:
 
|permissions=true
 
|permissions=true
 
|delay=0
 
|delay=0
 +
|description=Play the specified sound at the specified volume and loop it indefinitely.
 +
The sound parameter can be the UUID of a sound or the name of a sound that is in the inventory of the target prim.
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 
 
//
 
//
 
// osLoopSound Script Example
 
// osLoopSound Script Example
 +
// Author: djphil
 
//
 
//
  
integer on = FALSE;
+
string soundName;
string soundname = "youresound"; //sound file name
+
integer power;
 
+
 
default
 
default
 
{
 
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         on = FALSE;
+
         // Get the first inventory sound name
         soundname = llGetInventoryName(INVENTORY_SOUND, 0);
+
         soundName = llGetInventoryName(INVENTORY_SOUND, 0);
 +
       
 +
        if (soundName == "")
 +
        {
 +
            llOwnerSay("Inventory sound missing ...");
 
         }
 
         }
 +
       
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to see osLoopSound usage.");
 +
        }
 +
    }
  
     touch_start(integer total_number)
+
     touch_start(integer number)
 
     {
 
     {
         if(llDetectedKey(0) != llGetOwner())
+
         if (power = !power)
        return;
+
        if(soundname != "")
+
 
         {
 
         {
             if(on)
+
             osLoopSound(1, soundName, 1.0);
            osStopSound(0);
+
        }
            else
+
 
             osLoopSound(0, soundname, 1);
+
        else
            on = !on;
+
        {
 +
             osStopSound(1);
 
         }
 
         }
 
     }
 
     }
 
}
 
}
 
 
</source>
 
</source>
|description=Play the specified sound at the specified volume and loop it indefinitely.
+
''' And with uuid: '''
 +
<source lang="lsl">
 +
//
 +
// osLoopSound Script Example
 +
// Author: djphil
 +
//
  
The sound parameter can be the UUID of a sound or the name of a sound that is in the inventory of the target prim.
+
string soundUuid = "5e191c7b-8996-9ced-a177-b2ac32bfea06";
|additional_info=
+
integer power;
This function was added in 0.9.0.1
+
Since 0.9.1 if target prim inventory does not contain the sound, the inventory of the prim containing the script calling this function is also checked
+
default
 +
{
 +
    state_entry()
 +
    {
 +
        if (osIsUUID(soundUuid))
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to see osLoopSound usage.");
 +
        }
 +
       
 +
        else
 +
        {
 +
            llOwnerSay("Invalid UUID detected ...");
 +
        }
 +
    }
 +
 
 +
    touch_start(integer number)
 +
    {
 +
        if (power = !power)
 +
        {
 +
            osLoopSound(1, soundUuid, 1.0);
 +
        }
 +
 
 +
        else
 +
        {
 +
            osStopSound(1);
 +
        }
 +
    }
 +
}
 +
</source>
 +
|additional_info=This function was added in 0.9.0.1
 +
Since 0.9.1 if target prim inventory does not contain the sound, the inventory of the prim containing the script calling this function is also checked.
 
}}
 
}}
 +
== See Also ==
 +
* [[osLoopSound]]
 +
* [[osLoopSoundMaster]]
 +
* [[osLoopSoundSlave]]

Latest revision as of 20:06, 5 December 2020

osLoopSound(integer linknum, string sound, float volume)
Play the specified sound at the specified volume and loop it indefinitely.

The sound parameter can be the UUID of a sound or the name of a sound that is in the inventory of the target prim.

Threat Level This function does not do a threat level check
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
//
// osLoopSound Script Example
// Author: djphil
//
 
string soundName;
integer power;
 
default
{
    state_entry()
    {
        // Get the first inventory sound name
        soundName = llGetInventoryName(INVENTORY_SOUND, 0);
 
        if (soundName == "")
        {
            llOwnerSay("Inventory sound missing ...");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Touch to see osLoopSound usage.");
        }
    }
 
    touch_start(integer number)
    {
        if (power = !power)
        {
            osLoopSound(1, soundName, 1.0);
        }
 
        else
        {
            osStopSound(1);
        }
    }
}

And with uuid:

//
// osLoopSound Script Example
// Author: djphil
//
 
string soundUuid = "5e191c7b-8996-9ced-a177-b2ac32bfea06";
integer power;
 
default
{
    state_entry()
    {
        if (osIsUUID(soundUuid))
        {
            llSay(PUBLIC_CHANNEL, "Touch to see osLoopSound usage.");
        }
 
        else
        {
            llOwnerSay("Invalid UUID detected ...");
        }
    }
 
    touch_start(integer number)
    {
        if (power = !power)
        {
            osLoopSound(1, soundUuid, 1.0);
        }
 
        else
        {
            osStopSound(1);
        }
    }
}
Notes
This function was added in 0.9.0.1

Since 0.9.1 if target prim inventory does not contain the sound, the inventory of the prim containing the script calling this function is also checked.


[edit] See Also

Personal tools
General
About This Wiki