Don't click here unless you want to be banned.

LSL Wiki : llTriggerSoundLimited

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl801.us.archive.org
llTriggerSoundLimited(string sound, float volume, vector tne, vector bsw)

Plays a transient sound NOT attached to an object with its audible range limited by the axis--aligned bounding box defined by tne (top-north-east) and bsw (bottom-south-west). The sound plays from a stationary position located at the center of the object at the time of the trigger. There is no limit to the number of triggered sounds which can be generated by an object, and calling llTriggerSound does not affect the attached sounds created by llPlaySound and llLoopSound. This is very useful for things like collision noises, explosions, etc. There is no way to stop or alter the volume of a sound triggered by this function.

It is polite to use this function where ever possible, especially to prevent your sounds spilling over on to your neighbor's land. Alternately, use the normal non-limited sound functions and exceedingly small volume settings, like 0.05, so that the sound is highly localized, though this is probably less useful for explosions, etc.

The values for tne and bsw are in region local coordinates. So, the points tne and bsw describe a box in the world. This box is unrelated to the scripted object's position. An avatar standing in this box will be able to hear the triggered sound (if they could hear it if it was played with just llTriggerSound. That is, they are not too far from the object triggering the sound and it is not too quiet). An avatar standing outside the box will not hear the sound.

Note: avatars walking into the box after the sound is triggered (no matter the length of the sound) will not hear the sound.

To get the values for tne and bsw, you can use the following method:

For example, if vector1 was <100,50,20> and vector2 was <10,75,60> then tne would be <100,75,60> and bsw would be <10,50,20>.

If you just want your scripted object's sounds not to spread too far, use this method:

llTriggerSoundLimited("soundname", 1.0, llGetPos() + <10,10,10>, llGetPos() - <10,10,10>);

This makes it so that people will only hear the sound if they're within around 10 meters, give or take some. Objects like slot machines would greatly benefit from this.

Q: Is there a way to have sound played so that only a specific agent can hear it?
A: llTriggerSoundLimited(sound, volume, llGetPos(), llGetPos()) in an HUD attachment will do the trick.
A: llPlaySound() will also do this in a hud attachment, and it'll be nondirectional.

You can also target a specific avatar in code like this:

touch_start(integer total_number)
{
    key av_key = llDetectedKey(0);
    if (av_key == llGetOwner())
    {
        /// do work for owner
    }
    else
    {
        vector pos = llDetectedPos(0);
        llTriggerSoundLimited("CantTouch", 1.0, pos + <0.1,0.1,0.1>, pos - <0.1,0.1,0.1>);
    }
}


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Sound
Comments [Hide comments/form]
Attach a comment to this page: