OsLoopSound
From OpenSimulator
(Difference between revisions)
(Script fixed) |
|||
Line 5: | Line 5: | ||
|delay=0 | |delay=0 | ||
|ossl_example=<source lang="lsl"> | |ossl_example=<source lang="lsl"> | ||
− | |||
// | // | ||
// osLoopSound Script Example | // osLoopSound Script Example | ||
// | // | ||
− | + | string soundName; | |
− | + | integer power; | |
− | + | ||
default | default | ||
{ | { | ||
state_entry() | 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 | + | touch_start(integer number) |
{ | { | ||
− | if( | + | if (power = !power) |
− | + | ||
− | + | ||
{ | { | ||
− | + | osLoopSound(LINK_THIS, soundName, 1.0); | |
− | + | } | |
− | + | ||
− | + | else | |
− | + | { | |
+ | osStopSound(LINK_THIS); | ||
} | } | ||
} | } | ||
} | } | ||
− | |||
</source> | </source> | ||
|description=Play the specified sound at the specified volume and loop it indefinitely. | |description=Play the specified sound at the specified volume and loop it indefinitely. |
Revision as of 09:44, 26 November 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 // 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(LINK_THIS, soundName, 1.0); } else { osStopSound(LINK_THIS); } } } | |
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 |