Jump to content

Sound on sit script


KesavaKantha
 Share

You are about to reply to a thread that has been inactive for 3302 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hmm. Well, that script has an error. Where it checks whether "avatar == NULL_KEY" it means to be testing "sittingAvatar" instead of "avatar" (otherwise the compile will fail with "ERROR : Name not defined within scope").

Also, as written, the script expects a sound file to be in the object's inventory, along with the script. If that's a problem, the script could be changed to reference a sound by UUID instead.

Link to comment
Share on other sites

The first argument to llPlaySound() can be either the name of an embedded sound file (as the script is written now) or the UUID "key" for a sound asset. So, instead of

llPlaySound(firstSoundInPrim, 1.0);

you could substitute

llPlaySound("00000000-0000-0000-0000-000000000107", 1.0);

but using your asset's UUID instead of that particular one (which is SND_MUNCH, the sound of eating a LindenWorld bird).

Link to comment
Share on other sites

I can't tell you how grateful I am for your assistance! It is still not working - here is what I have so far. Does it look okay to you? Not sure where the problem lies. It is one prim, I even tried a script to make the sound play on touch to no avail.

 

vector sit_position = <0.0, 0.0, -0.1>;
// here an euler rot
vector sit_rotation = <0.0, 0.0, 0.0>;

default
{
state_entry()
{
llSitTarget(sit_position, llEuler2Rot(sit_rotation * DEG_TO_RAD));
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key sittingAvatar = llAvatarOnSitTarget();

// when there's no avatar sitting, stop running code here
if (sittingavatar == NULL_KEY) return;

string firstSoundInPrim = llGetInventoryName(INVENTORY_SOUND, 0);
llPlaySound("2e1d11a8-59fe-caa5-058c-6bb1b64f2d2a", 1.0);
}
}
}

Link to comment
Share on other sites

Ah. Yeah, LSL is case-sensitive, so where you have "sittingavatar" you want "sittingAvatar" instead.

I should maybe also mention that this sample script is setting a "sit target" in the state_entry section of the script, and it's possible that this will conflict with another script in the object, so we could change this to a simpler approach that doesn't set that target.

Or, if this is going to be the only script in the object (no animation on sit), then you may want to change the values for the llSitTarget() call; here's one way to find values for those.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3302 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...