OsAdjustSoundVolume

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Fixed some cut and paste errors)
(Add new exemples)
Line 4: Line 4:
 
|permissions=true
 
|permissions=true
 
|delay=0.1
 
|delay=0.1
 +
|description=Adjust the volume of attached sound for a prim in a linkset.
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
// Example use of osAdjustSoundVolume
+
//
 
+
// osAdjustSoundVolume Script Example
integer which_prim = 2;
+
//
 +
 +
string sound;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        sound = llGetInventoryName(INVENTORY_SOUND, 0);
 +
 +
        if (sound == "")
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Inventory sound missing ...");
 +
        }
 +
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to hear osAdjustSoundVolume running.");
 +
        }
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        float volume = llFrand(1.0);
 +
        osAdjustSoundVolume(1, volume);
 +
        osPlaySound(1, sound, volume);
 +
        llSay(PUBLIC_CHANNEL, "The volume of the primitive (link 1) has been adjusted to " + (string)volume);
 +
    }
 +
}
 +
</source>
 +
'''And with uuid:'''
 +
<source lang="lsl">
 +
//
 +
// osAdjustSoundVolume Script Example
 +
//
 +
 +
string sound = "ed124764-705d-d497-167a-182cd9fa2e6c";
  
 
default
 
default
Line 13: Line 50:
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         llListen(10, "", llGetOwner(), "");
+
         if (osIsUUID(sound))
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to hear osAdjustSoundVolume running.");
 +
        }
 +
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Invalid uuid detected ...");
 +
        }
 
     }
 
     }
 
   
 
   
     listen(integer channel, string name, key id, string msg)
+
     touch_start(integer number)
 
     {
 
     {
         float volume = (float)msg;
+
         float volume = llFrand(1.0);
         osAdjustSoundVolume(which_prim, volume);
+
         osAdjustSoundVolume(1, volume);
         llOwnerSay("Volume in prim " + (string)which_prim + " was set to " + (string)volume);
+
         osPlaySound(1, sound, volume);
 +
        llSay(PUBLIC_CHANNEL, "The volume of the primitive (link 1) has been adjusted to " + (string)volume);
 
     }
 
     }
}</source>
+
}
|description=Adjust the volume of attached sound for a prim in a linkset.
+
</source>
 
|additional_info=This function was added in 0.9.0.1
 
|additional_info=This function was added in 0.9.0.1
 
}}
 
}}

Revision as of 14:59, 1 December 2020

osAdjustSoundVolume(integer linknum, float volume)
Adjust the volume of attached sound for a prim in a linkset.
Threat Level This function does not do a threat level check
Permissions Use of this function is always allowed by default
Extra Delay 0.1 seconds
Example(s)
//
// osAdjustSoundVolume Script Example
//
 
string sound;
 
default
{
    state_entry()
    {
        sound = llGetInventoryName(INVENTORY_SOUND, 0);
 
        if (sound == "")
        {
            llSay(PUBLIC_CHANNEL, "Inventory sound missing ...");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Touch to hear osAdjustSoundVolume running.");
        }
    }
 
    touch_start(integer number)
    {
        float volume = llFrand(1.0);
        osAdjustSoundVolume(1, volume);
        osPlaySound(1, sound, volume);
        llSay(PUBLIC_CHANNEL, "The volume of the primitive (link 1) has been adjusted to " + (string)volume);
    }
}

And with uuid:

//
// osAdjustSoundVolume Script Example
//
 
string sound = "ed124764-705d-d497-167a-182cd9fa2e6c";
 
default
{
    state_entry()
    {
        if (osIsUUID(sound))
        {
            llSay(PUBLIC_CHANNEL, "Touch to hear osAdjustSoundVolume running.");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Invalid uuid detected ...");
        }
    }
 
    touch_start(integer number)
    {
        float volume = llFrand(1.0);
        osAdjustSoundVolume(1, volume);
        osPlaySound(1, sound, volume);
        llSay(PUBLIC_CHANNEL, "The volume of the primitive (link 1) has been adjusted to " + (string)volume);
    }
}
Notes
This function was added in 0.9.0.1


Personal tools
General
About This Wiki